Extensions.Hosting.Wpf.Threading
3.4.0
.NET 6.0
This package targets .NET 6.0. The package is compatible with this framework or higher.
.NET Core 3.1
This package targets .NET Core 3.1. The package is compatible with this framework or higher.
.NET Framework 4.6.2
This package targets .NET Framework 4.6.2. The package is compatible with this framework or higher.
dotnet add package Extensions.Hosting.Wpf.Threading --version 3.4.0
NuGet\Install-Package Extensions.Hosting.Wpf.Threading -Version 3.4.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Extensions.Hosting.Wpf.Threading" Version="3.4.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Extensions.Hosting.Wpf.Threading --version 3.4.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Extensions.Hosting.Wpf.Threading, 3.4.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Extensions.Hosting.Wpf.Threading as a Cake Addin #addin nuget:?package=Extensions.Hosting.Wpf.Threading&version=3.4.0 // Install Extensions.Hosting.Wpf.Threading as a Cake Tool #tool nuget:?package=Extensions.Hosting.Wpf.Threading&version=3.4.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Microsoft.Extensions.Hosting.Wpf.Threading
Extension library for Microsoft.Extensions.Hosting.Wpf
. This adds support to switch to Main UI Thread or ThreadPool Thread with the help of Microsoft.VisualStudio.Threading
.
This can be really useful when using WPF inside Microsoft.Extensions.Hosting
since sometimes you might need to show UI from not UI thread, for example during some network request.
Getting Started
Install nuget
Install-Package Extensions.Hosting.Wpf.Threading
Register service
private static void ConfigureServices(HostBuilderContext hostContext, IServiceCollection services)
{
services.AddWpf<App>();
services.AddThreadSwitching(); //<--- new line
}
Example Usage
private readonly JoinableTaskFactory _joinableTaskFactory;
public SomeConstructor(JoinableTaskFactory joinableTaskFactory)
{
_joinableTaskFactory = joinableTaskFactory;
}
private async Task SomeOperationAsync() {
// on the caller's thread.
await DoAsync();
// Now switch to a threadpool thread explicitly.
await TaskScheduler.Default;
// Now switch to the Main thread to talk to some STA object.
await _joinableTaskFactory.SwitchToMainThreadAsync();
STAService.DoSomething();
}
for more use cases please visit Microsoft.VisualStudio.Threading repository.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net6.0-windows7.0 is compatible. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net7.0-windows7.0 is compatible. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net8.0-windows7.0 is compatible. |
.NET Core | netcoreapp3.1 is compatible. |
.NET Framework | net462 is compatible. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 is compatible. net481 was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
.NETCoreApp 3.1
- Extensions.Hosting.Wpf (>= 3.4.0)
- Microsoft.VisualStudio.Threading (>= 17.5.22)
- Microsoft.VisualStudio.Threading.Analyzers (>= 17.5.22)
-
.NETFramework 4.6.2
- Extensions.Hosting.Wpf (>= 3.4.0)
- Microsoft.VisualStudio.Threading (>= 17.5.22)
- Microsoft.VisualStudio.Threading.Analyzers (>= 17.5.22)
-
.NETFramework 4.8
- Extensions.Hosting.Wpf (>= 3.4.0)
- Microsoft.VisualStudio.Threading (>= 17.5.22)
- Microsoft.VisualStudio.Threading.Analyzers (>= 17.5.22)
-
net6.0-windows7.0
- Extensions.Hosting.Wpf (>= 3.4.0)
- Microsoft.VisualStudio.Threading (>= 17.5.22)
- Microsoft.VisualStudio.Threading.Analyzers (>= 17.5.22)
-
net7.0-windows7.0
- Extensions.Hosting.Wpf (>= 3.4.0)
- Microsoft.VisualStudio.Threading (>= 17.5.22)
- Microsoft.VisualStudio.Threading.Analyzers (>= 17.5.22)
-
net8.0-windows7.0
- Extensions.Hosting.Wpf (>= 3.4.0)
- Microsoft.VisualStudio.Threading (>= 17.5.22)
- Microsoft.VisualStudio.Threading.Analyzers (>= 17.5.22)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.