Oakrey.Async.Windows
1.0.0
dotnet add package Oakrey.Async.Windows --version 1.0.0
NuGet\Install-Package Oakrey.Async.Windows -Version 1.0.0
<PackageReference Include="Oakrey.Async.Windows" Version="1.0.0" />
<PackageVersion Include="Oakrey.Async.Windows" Version="1.0.0" />
<PackageReference Include="Oakrey.Async.Windows" />
paket add Oakrey.Async.Windows --version 1.0.0
#r "nuget: Oakrey.Async.Windows, 1.0.0"
#addin nuget:?package=Oakrey.Async.Windows&version=1.0.0
#tool nuget:?package=Oakrey.Async.Windows&version=1.0.0
O.Async.Windows
Overview
The Async.Windows project is a specialized library designed to enhance asynchronous programming in WPF (Windows Presentation Foundation) applications. It provides utilities and abstractions to simplify working with asynchronous workflows, ensuring smooth integration with the WPF threading model and UI responsiveness. This library is particularly useful for developers building WPF applications that require efficient task management, UI thread synchronization, and event handling.
Features of Async.Windows
UI Task Management
Classes:
- UiTask,
- UiTask<T>,
- UiTaskMethodBuilder,
- UiTaskMethodBuilderGeneric<T>
Description:
- These classes provide custom task implementations (UiTask and UiTask<T>) and method builders (UiTaskMethodBuilder and UiTaskMethodBuilderGeneric<T>) tailored for WPF applications.
- They ensure that asynchronous operations are executed on the UI thread when necessary, leveraging the WPF Dispatcher.
Key Highlights:
- Automatic context switching to the UI thread using Dispatcher.
- Seamless integration with the async/await pattern.
- Support for both non-generic and generic tasks.
Thread-Safe Invocation
Class: Invoker
Description:
- Provides utility methods to safely invoke actions or functions on the WPF UI thread.
Key Highlights:
- Invoke(Action action) and Invoke<T>(Func<T> func) for synchronous execution.
- InvokeAsync(Action action) and InvokeAsync<T>(Func<T> func) for asynchronous execution.
- Automatically checks and switches to the UI thread if the current thread does not have access.
Event Handling Utilities
Class: Events Description:
- Contains helper methods for managing events and timers in WPF applications. Key Highlights:
- UnsubscribeTimer: Safely unsubscribes and stops a DispatcherTimer.
- WaitForEvent: Blocks the current thread until an event is signaled or a timeout occurs, using a DispatcherFrame to keep the UI responsive.
Dispatcher Integration
The library heavily relies on the WPF Dispatcher to ensure that all asynchronous operations and event handling are executed on the correct thread, maintaining UI thread safety.
Example Use Cases
- Asynchronous UI Updates: Use UiTask or UiTask<T> to perform background operations and update the UI seamlessly.
- Thread-Safe UI Invocation: Use Invoker.Invoke or Invoker.InvokeAsync to safely execute code on the UI thread from background threads.
- Timer Management: Use Events.UnsubscribeTimer to cleanly manage DispatcherTimer instances and avoid memory leaks.
- Event Waiting: Use Events.WaitForEvent to block execution until a specific event occurs, while keeping the UI responsive.
Installation
You can install the package via NuGet Package Manager, Package Manager Console or the .NET CLI.
NuGet Package Manager
- Open your project in Visual Studio.
- Navigate to Tools > NuGet Package Manager > Manage NuGet Packages for Solution....
- Search for
Oakrey.Async.Windows
and click Install.
.NET CLI
Run the following command in your terminal:
dotnet add package Oakrey.Async.Windows
Package Manager Console
Run the following command in your Package Manager Console:
Install-Package Oakrey.Async.Windows
Requirements
- .NET 8 or higher
Project Information
- Author: Oakrey
- Company: Oakrey
- License: MIT
- Repository: Git Repository
- Project URL: Project Website
Contributing
Contributions are welcome! Feel free to open issues or submit pull requests to improve the package.
License
This project is licensed under the MIT License. See the LICENSE file for details.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0-windows7.0 is compatible. net9.0-windows was computed. |
-
net8.0-windows7.0
- No dependencies.
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Oakrey.Async.Windows:
Package | Downloads |
---|---|
Oakrey.Applications.UI
A .NET library for building modern WPF user interfaces, featuring notifications, prompts, tabbed windows, and support for themes and animations |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.0.0 | 199 | 4/16/2025 |