AsyncClipboardService 1.7.1
dotnet add package AsyncClipboardService --version 1.7.1
NuGet\Install-Package AsyncClipboardService -Version 1.7.1
<PackageReference Include="AsyncClipboardService" Version="1.7.1" />
paket add AsyncClipboardService --version 1.7.1
#r "nuget: AsyncClipboardService, 1.7.1"
// Install AsyncClipboardService as a Cake Addin #addin nuget:?package=AsyncClipboardService&version=1.7.1 // Install AsyncClipboardService as a Cake Tool #tool nuget:?package=AsyncClipboardService&version=1.7.1
AsyncWindowsClipboard
AsyncWindowsClipboard is thread-safe, asynchronous windows clipboard service with retry strategy for .NET
What it is
- It gives async/await syntax to communicate with Windows clipboard API's.
- It is thread safe.
- It gives lower (binary) level read & write access to strings in clipboard than .NET implementation.
- Implements retry strategies to connect to the clipboard when it's locked.
How it works
AsyncClipboardService
ensures that:
- The
Task
s for the communication always run in the same thread which makes the communication thread safe. - The thread is in Single Thread Apartment (STA) model. WPF & Windows Forms uses COM interop to communicate with clipboard in STA state. Running the thread in same apartment state ensures that the library functions well. Read more at MSDN 1, 2, 3.
- Implements retry strategy to ensure clipboard operation ends successfully.
How to use
Simple usage
You can use a new instance of WindowsClipboardService
to retrieve data. It's okay to use the instance from different threads.
var clipboardService = new WindowsClipboardService();
await clipboardService.SetTextAsync("Hello world"); // Sets the text
var data = await clipboardService.GetTextAsync(); // Reads "Hello world"
Recommended usage
However, it's recommended to use WindowsClipboardService
with a timeout strategy, as it'll then wait (in a spinning state) for the thread that blocks the windows api instead of failing. You can activate the timeout strategy by setting it in the constructor:
var clipboardService = new WindowsClipboardService(timeout:TimeSpan.FromMilliseconds(200));
// or via its property
var clipboardService = new ClipboardService { Timeout = TimeSpan.FromMilliseconds(200) };
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. 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. 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. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net45 is compatible. net451 was computed. net452 was computed. net46 was computed. net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETFramework 4.5
- No dependencies.
-
.NETStandard 2.0
- No dependencies.
NuGet packages (1)
Showing the top 1 NuGet packages that depend on AsyncClipboardService:
Package | Downloads |
---|---|
BlishHUD
Package Description |
GitHub repositories (1)
Showing the top 1 popular GitHub repositories that depend on AsyncClipboardService:
Repository | Stars |
---|---|
blish-hud/Blish-HUD
A Guild Wars 2 overlay with extreme extensibility through compiled modules.
|
- Exceptions are now properly serializable.
- Fixed delay for retrying connection is being ignored.