> For the complete documentation index, see [llms.txt](https://cours.davidannebicque.fr/but-info/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://cours.davidannebicque.fr/but-info/astuces-wpf.md).

# Astuces WPF

## Timer

```csharp
private void Button_Click(object sender, RoutedEventArgs e)
{
    System.Windows.Threading.DispatcherTimer dispatcherTimer = new System.Windows.Threading.DispatcherTimer();
    dispatcherTimer.Tick += new EventHandler(dispatcherTimer_Tick);
    dispatcherTimer.Interval = TimeSpan.FromMilliseconds(20);;
    dispatcherTimer.Start();
}
```

```csharp
private void dispatcherTimer_Tick(object sender, EventArgs e)
{
    this.runCycleApi();
}
```
