diff --git a/docs/windows/Extensions/DispatcherQueueExtensions.md b/docs/windows/Extensions/DispatcherQueueExtensions.md index 6c5a4aac..7a35d439 100644 --- a/docs/windows/Extensions/DispatcherQueueExtensions.md +++ b/docs/windows/Extensions/DispatcherQueueExtensions.md @@ -16,11 +16,22 @@ icon: Assets/Extensions.png The `DispatcherQueueExtensions` type provides a collection of extensions methods for [`DispatcherQueue`](/uwp/api/windows.system.dispatcherqueue) objects that makes it easier to execute code on a specific UI thread. A `DispatcherQueue` instance can be retrieved and cached for later use, and then used through any of the available helper methods to dispatch a delegate invocation on it. +## Setup + +First, add the [`CommunityToolkit.WinUI.Extensions`](https://www.nuget.org/packages/CommunityToolkit.WinUI.Extensions) to your project. See [Get started](../getting-started.md). Then: + +```csharp +// Imports the extension methods +using CommunityToolkit.WinUI; +``` + ## Syntax The `DispatcherQueueExtensions` type exposes a number of overloads of its `EnqueueAsync` method to dispatch either synchronous or asynchronous delegates, and to optionally have them return a value that is then relayed back to the caller through an awaitable task. Here are some examples of how these extension methods can be used: ```csharp +using CommunityToolkit.WinUI; + // Get a DispatcherQueue instance for later use. This has to be called on the UI thread, // but it can then be cached for later use and accessed from a background thread as well. DispatcherQueue dispatcherQueue = DispatcherQueue.GetForCurrentThread();