Clock Clock Clock Clock Class


Maintains run-time timing state for a Timeline.

public ref class Clock : System::Windows::Threading::DispatcherObject
public class Clock : System.Windows.Threading.DispatcherObject
type Clock = class
    inherit DispatcherObject
Public Class Clock
Inherits DispatcherObject


A Timeline, by itself, doesn't actually do anything other than describe a segment of time. It's the timeline's Clock object that does the real work: it maintains timing-related run-time state for the timeline.

In most cases, a clock is created automatically for your timeline. When you animate by using a Storyboard or the BeginAnimation method, clocks are automatically created for your timelines and animations and applied to their targeted properties. For examples, see How to: Animate a Property by Using a Storyboard and How to: Animate a Property Without Using a Storyboard.

You can also create a Clock explicitly by using the CreateClock method. In performance-intensive scenarios, such as animating large numbers of similar objects, managing your own Clock use can provide performance benefits.

Clocks are arranged in trees that match the structure of the Timeline objects tree from which they are created. The root clock of such a timing tree can be interactively manipulated (paused, resumed, stopped, and so on) by retrieving its Controller. Non-root clocks cannot be directly controlled.

Once created, a clock cannot be modified (but it can be manipulated).

Using a Timeline as a Timer

A timeline's clock will only progress when there's an event handler associated with it or (in the case of an AnimationClock object) it is associated with a property. For this reason (and others), it's not recommended that you use a Timeline as a timer.

Notes to Inheritors

Derived classes should implement GetCurrentTimeCore() if they want to modify how time flows for this clock. Derived classes can be made to do additional work when the clock repeats, skips, seeks, begins, pauses, resumes, or stops by overriding the DiscontinuousTimeMovement(), SpeedChanged(), and Stopped() methods.


Clock(Timeline) Clock(Timeline) Clock(Timeline) Clock(Timeline)

Initializes a new instance of the Clock class, using the specified Timeline as a template. The new Clock object has no children.


Controller Controller Controller Controller

Gets a ClockController that can be used to start, pause, resume, seek, skip, stop, or remove this Clock.

CurrentGlobalSpeed CurrentGlobalSpeed CurrentGlobalSpeed CurrentGlobalSpeed

Gets the rate at which the clock's time is currently progressing, compared to real-world time.

CurrentGlobalTime CurrentGlobalTime CurrentGlobalTime CurrentGlobalTime

Gets the current global time, as established by the WPF timing system.

CurrentIteration CurrentIteration CurrentIteration CurrentIteration

Get the current iteration of this clock.

CurrentProgress CurrentProgress CurrentProgress CurrentProgress

Gets the current progress of this Clock within its current iteration.

CurrentState CurrentState CurrentState CurrentState

Gets a value indicating whether the clock is currently Active, Filling, or Stopped.

CurrentTime CurrentTime CurrentTime CurrentTime

Gets this clock's current time within its current iteration.

Dispatcher Dispatcher Dispatcher Dispatcher

Gets the Dispatcher this DispatcherObject is associated with.

(Inherited from DispatcherObject)
HasControllableRoot HasControllableRoot HasControllableRoot HasControllableRoot

Gets a value that indicates whether this Clock is part of a controllable clock tree.

IsPaused IsPaused IsPaused IsPaused

Gets a value that indicates whether this Clock, or any of its parents, is paused.

NaturalDuration NaturalDuration NaturalDuration NaturalDuration

Gets the natural duration of this clock's Timeline.

Parent Parent Parent Parent

Gets the clock that is the parent of this clock.

Timeline Timeline Timeline Timeline

Gets the Timeline from which this Clock was created.


CheckAccess() CheckAccess() CheckAccess() CheckAccess()

Determines whether the calling thread has access to this DispatcherObject.

(Inherited from DispatcherObject)
DiscontinuousTimeMovement() DiscontinuousTimeMovement() DiscontinuousTimeMovement() DiscontinuousTimeMovement()

When implemented in a derived class, will be invoked whenever a clock repeats, skips, or seeks.

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetCanSlip() GetCanSlip() GetCanSlip() GetCanSlip()

Returns whether the Clock has its own external time source, which may require synchronization with the timing system.

GetCurrentTimeCore() GetCurrentTimeCore() GetCurrentTimeCore() GetCurrentTimeCore()

Gets this clock's current time within its current iteration.

GetHashCode() GetHashCode() GetHashCode() GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetType() GetType() GetType() GetType()

Gets the Type of the current instance.

(Inherited from Object)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
SpeedChanged() SpeedChanged() SpeedChanged() SpeedChanged()

When implemented in a derived class, will be invoked whenever a clock begins, skips, pauses, resumes, or when the clock's SpeedRatio is modified.

Stopped() Stopped() Stopped() Stopped()

When implemented in a derived class, will be invoked whenever a clock is stopped using the Stop() method.

ToString() ToString() ToString() ToString()

Returns a string that represents the current object.

(Inherited from Object)
VerifyAccess() VerifyAccess() VerifyAccess() VerifyAccess()

Enforces that the calling thread has access to this DispatcherObject.

(Inherited from DispatcherObject)


Completed Completed Completed Completed

Occurs when this clock has completely finished playing.

CurrentGlobalSpeedInvalidated CurrentGlobalSpeedInvalidated CurrentGlobalSpeedInvalidated CurrentGlobalSpeedInvalidated

Occurs when the clock's speed is updated.

CurrentStateInvalidated CurrentStateInvalidated CurrentStateInvalidated CurrentStateInvalidated

Occurs when the clock's CurrentState property is updated.

CurrentTimeInvalidated CurrentTimeInvalidated CurrentTimeInvalidated CurrentTimeInvalidated

Occurs when this clock's CurrentTime becomes invalid.

RemoveRequested RemoveRequested RemoveRequested RemoveRequested

Occurs when the Remove() method is called on this Clock or one of its parent clocks.

Applies to