This documentation is archived and is not being maintained.

Stopwatch.IsRunning Property

Gets a value indicating whether the Stopwatch timer is running.

Namespace: System.Diagnostics
Assembly: System (in system.dll)

Public ReadOnly Property IsRunning As Boolean
Dim instance As Stopwatch
Dim value As Boolean

value = instance.IsRunning

/** @property */
public boolean get_IsRunning ()

public function get IsRunning () : boolean

Not applicable.

Property Value

true if the Stopwatch instance is currently running and measuring elapsed time for an interval; otherwise, false.

A Stopwatch instance begins running with a call to Start or StartNew. The instance stops running with a call to Stop or Reset.

The following example uses the Stopwatch class to implement start, stop, reset, and lap-time buttons in a Windows form application. This code example is part of a larger example provided for the Stopwatch class.

If stopWatch.IsRunning Then

    ' Stop the timer; show the start and reset buttons.
    buttonStartStop.Text = "Start"
    buttonLapReset.Text = "Reset"
    ' Start the timer; show the stop and lap buttons.
    buttonStartStop.Text = "Stop"
    buttonLapReset.Text = "Lap"
    labelLap.Visible = False
    labelLapPrompt.Visible = False
End If

if (stopWatch.get_IsRunning()) {
    // Stop the timer; show the start and reset buttons.
else {
    // Start the timer; show the stop and lap buttons.

Windows 98, Windows Server 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0

XNA Framework

Supported in: 1.0