--- title: "How to: Receive Notification When a Clock's State Changes" description: Learn how to receive notification when a Clock's state changes. ms.date: "03/30/2017" ms.custom: devdivchpfy22 dev_langs: - "csharp" - "vb" helpviewer_keywords: - "clocks [WPF], notification of state changes" - "notifications [WPF], clocks' state changes" ms.assetid: ecb10fc9-d0c2-45c3-b0a1-7b11baa733da --- # How to: Receive Notification When a Clock's State Changes A clock's event occurs when its becomes invalid, such as when the clock starts or stops. You can register for this event with directly using a , or you can register using a . In the following example, a and two objects are used to animate the width of two rectangles. The event is used to listen for clock state changes. ## Example [!code-xaml[timingbehaviors_snip#_graphicsmm_StateExampleMarkupWholePage](~/samples/snippets/csharp/VS_Snippets_Wpf/timingbehaviors_snip/CSharp/StateExample.xaml#_graphicsmm_stateexamplemarkupwholepage)] [!code-csharp[timingbehaviors_snip#_graphicsmm_StateEventHandlers](~/samples/snippets/csharp/VS_Snippets_Wpf/timingbehaviors_snip/CSharp/StateExample.xaml.cs#_graphicsmm_stateeventhandlers)] [!code-vb[timingbehaviors_snip#_graphicsmm_StateEventHandlers](~/samples/snippets/visualbasic/VS_Snippets_Wpf/timingbehaviors_snip/visualbasic/stateexample.xaml.vb#_graphicsmm_stateeventhandlers)] The following illustration shows the different states the animations enter as the parent timeline (*Storyboard*) progresses. ![Clock states for a Storyboard with two animations](./media/graphicsmm-3timelines.png "graphicsmm_3timelines") The following table shows the times at which *Animation1*'s event fires: | Time (Seconds) | State | |----------------|-------| |1|Active| |10|Active| |19|Stopped| |21|Active| |30|Active| |39|Stopped| The following table shows the times at which *Animation2*'s event fires: | Time (Seconds) | State | |----------------|-------| |1|Active| |9|Filling| |11|Active| |19|Stopped| |21|Active| |29|Filling| |31|Active| |39|Stopped| Notice that *Animation1*'s event fires at 10 seconds, even though its state remains . That's because its state changed at 10 seconds, but it changed from to and then back to in the same tick.