GuiDispatcher.Sharp.Wpf
1.1.2
dotnet add package GuiDispatcher.Sharp.Wpf --version 1.1.2
NuGet\Install-Package GuiDispatcher.Sharp.Wpf -Version 1.1.2
<PackageReference Include="GuiDispatcher.Sharp.Wpf" Version="1.1.2" />
<PackageVersion Include="GuiDispatcher.Sharp.Wpf" Version="1.1.2" />
<PackageReference Include="GuiDispatcher.Sharp.Wpf" />
paket add GuiDispatcher.Sharp.Wpf --version 1.1.2
#r "nuget: GuiDispatcher.Sharp.Wpf, 1.1.2"
#:package GuiDispatcher.Sharp.Wpf@1.1.2
#addin nuget:?package=GuiDispatcher.Sharp.Wpf&version=1.1.2
#tool nuget:?package=GuiDispatcher.Sharp.Wpf&version=1.1.2
GuiDispatcher.Sharp.Wpf
WPF implementation of GuiDispatcher.Sharp for .NET 10 on Windows.
Use this adapter in WPF applications that need to expose the UI thread through
the platform-neutral IGuiDispatcher and IGuiTimer contracts.
Install
<PackageReference Include="GuiDispatcher.Sharp.Wpf" Version="1.1.*" />
This package pulls in GuiDispatcher.Sharp 1.1.2 or later, below 2.0. WPF is
provided by the Microsoft.WindowsDesktop.App.WPF framework included with
.NET for Windows.
Usage
Register the application dispatcher explicitly when constructing services:
using GuiDispatcher.Sharp.Contracts;
using GuiDispatcher.Sharp.Wpf;
services.AddSingleton<IGuiDispatcher>(
_ => new WpfGuiDispatcher(Application.Current.Dispatcher));
The parameterless constructor is also suitable when dependency injection creates the service on the WPF UI thread:
services.AddSingleton<IGuiDispatcher, WpfGuiDispatcher>();
If no Application exists, the parameterless constructor requires a dispatcher
to have already been created on the current thread. Passing the dispatcher
explicitly avoids accidentally binding the adapter to a worker thread.
await dispatcher.InvokeAsync(() =>
{
viewModel.Apply(result);
});
using var timer = dispatcher.CreateTimer(TimeSpan.FromSeconds(1));
timer.Tick += (_, _) => viewModel.Refresh();
timer.Start();
InvokeAsync(Func<Task>) unwraps WPF's DispatcherOperation<Task>, so the
returned task completes only after the asynchronous callback finishes.
Requirements
- Windows
- .NET 10 (
net10.0-windows) - WPF
NuGet publishing
Publishing uses NuGet Trusted Publishing from GitHub Actions, without a stored API key. Configure this policy on nuget.org before pushing the first release tag:
| Field | Value |
|---|---|
| Repository owner | buchmiet |
| Repository | GuiDispatcher.Sharp.Wpf |
| Workflow file | publish-nuget.yml |
| Environment | production |
Releasing
Releases are cut by pushing a vX.Y.Z tag. Before tagging:
- Bump
<Version>inGuiDispatcher.Sharp.Wpf.csproj. - Move the relevant
[Unreleased]entries inCHANGELOG.mdinto a dated release section. - Commit both changes.
- Tag and push:
git tag vX.Y.Z && git push origin vX.Y.Z.
For a coordinated release of the complete package family, follow the family release guide.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0-windows7.0 is compatible. |
-
net10.0-windows7.0
- GuiDispatcher.Sharp (>= 1.1.2 && < 2.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.