VOOZH about

URL: https://www.nuget.org/packages/AsyncAwaitBestPractices.MVVM/

⇱ NuGet Gallery | AsyncAwaitBestPractices.MVVM 10.0.0




AsyncAwaitBestPractices.MVVM 10.0.0

dotnet add package AsyncAwaitBestPractices.MVVM --version 10.0.0
 
 
NuGet\Install-Package AsyncAwaitBestPractices.MVVM -Version 10.0.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="AsyncAwaitBestPractices.MVVM" Version="10.0.0" />
 
 
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="AsyncAwaitBestPractices.MVVM" Version="10.0.0" />
 
Directory.Packages.props
<PackageReference Include="AsyncAwaitBestPractices.MVVM" />
 
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add AsyncAwaitBestPractices.MVVM --version 10.0.0
 
 
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: AsyncAwaitBestPractices.MVVM, 10.0.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.
#:package AsyncAwaitBestPractices.MVVM@10.0.0
 
 
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=AsyncAwaitBestPractices.MVVM&version=10.0.0
 
Install as a Cake Addin
#tool nuget:?package=AsyncAwaitBestPractices.MVVM&version=10.0.0
 
Install as a Cake Tool
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

AsyncAwaitBestPractices.MVVM

👁 NuGet

  • Available on NuGet: https://www.nuget.org/packages/AsyncAwaitBestPractices.MVVM/

  • Allows for Task to safely be used asynchronously with ICommand:

    • IAsyncCommand : ICommand
    • AsyncCommand : IAsyncCommand
    • IAsyncCommand<T> : ICommand
    • AsyncCommand<T> : IAsyncCommand<T>
    • IAsyncCommand<TExecute, TCanExecute> : IAsyncCommand<TExecute>
    • AsyncCommand<TExecute, TCanExecute> : IAsyncCommand<TExecute, TCanExecute>
  • Allows for ValueTask to safely be used asynchronously with ICommand:

    • IAsyncValueCommand : ICommand
    • AsyncValueCommand : IAsyncValueCommand
    • IAsyncValueCommand<T> : ICommand
    • AsyncValueCommand<T> : IAsyncValueCommand<T>
    • IAsyncValueCommand<TExecute, TCanExecute> : IAsyncValueCommand<TExecute>
    • AsyncValueCommand<TExecute, TCanExecute> : IAsyncValueCommand<TExecute, TCanExecute>
  • Usage instructions

Setup

AsyncCommand

Allows for Task to safely be used asynchronously with ICommand:

  • AsyncCommand<TExecute, TCanExecute> : IAsyncCommand<TExecute, TCanExecute>
  • IAsyncCommand<TExecute, TCanExecute> : IAsyncCommand<TExecute>
  • AsyncCommand<T> : IAsyncCommand<T>
  • IAsyncCommand<T> : ICommand
  • AsyncCommand : IAsyncCommand
  • IAsyncCommand : ICommand
public AsyncCommand(Func<TExecute, Task> execute,
 Func<TCanExecute, bool>? canExecute = null,
 Action<Exception>? onException = null,
 bool continueOnCapturedContext = false)
public AsyncCommand(Func<T, Task> execute,
 Func<object?, bool>? canExecute = null,
 Action<Exception>? onException = null,
 bool continueOnCapturedContext = false)
public AsyncCommand(Func<Task> execute,
 Func<object?, bool>? canExecute = null,
 Action<Exception>? onException = null,
 bool continueOnCapturedContext = false)
public class ExampleClass
{
 bool _isBusy;

 public ExampleClass()
 {
 ExampleAsyncCommand = new AsyncCommand(ExampleAsyncMethod);
 ExampleAsyncIntCommand = new AsyncCommand<int>(ExampleAsyncMethodWithIntParameter);
 ExampleAsyncIntCommandWithCanExecute = new AsyncCommand<int, int>(ExampleAsyncMethodWithIntParameter, CanExecuteInt);
 ExampleAsyncExceptionCommand = new AsyncCommand(ExampleAsyncMethodWithException, onException: ex => Console.WriteLine(ex.ToString()));
 ExampleAsyncCommandWithCanExecuteChanged = new AsyncCommand(ExampleAsyncMethod, _ => !IsBusy);
 ExampleAsyncCommandReturningToTheCallingThread = new AsyncCommand(ExampleAsyncMethod, continueOnCapturedContext: true);
 }

 public IAsyncCommand ExampleAsyncCommand { get; }
 public IAsyncCommand<int> ExampleAsyncIntCommand { get; }
 public IAsyncCommand<int, int> ExampleAsyncIntCommandWithCanExecute { get; }
 public IAsyncCommand ExampleAsyncExceptionCommand { get; }
 public IAsyncCommand ExampleAsyncCommandWithCanExecuteChanged { get; }
 public IAsyncCommand ExampleAsyncCommandReturningToTheCallingThread { get; }
 
 public bool IsBusy
 {
 get => _isBusy;
 set
 {
 if (_isBusy != value)
 {
 _isBusy = value;
 ExampleAsyncCommandWithCanExecuteChanged.RaiseCanExecuteChanged();
 }
 }
 }

 async Task ExampleAsyncMethod()
 {
 await Task.Delay(1000);
 }
 
 async Task ExampleAsyncMethodWithIntParameter(int parameter)
 {
 await Task.Delay(parameter);
 }

 async Task ExampleAsyncMethodWithException()
 {
 await Task.Delay(1000);
 throw new Exception();
 }

 bool CanExecuteInt(int count)
 {
 if(count > 2)
 return true;
 
 return false;
 }

 void ExecuteCommands()
 {
 _isBusy = true;
 
 try
 {
 ExampleAsyncCommand.Execute(null);
 ExampleAsyncIntCommand.Execute(1000);
 ExampleAsyncExceptionCommand.Execute(null);
 ExampleAsyncCommandReturningToTheCallingThread.Execute(null);
 
 if(ExampleAsyncCommandWithCanExecuteChanged.CanExecute(null))
 ExampleAsyncCommandWithCanExecuteChanged.Execute(null);
 
 if(ExampleAsyncIntCommandWithCanExecute.CanExecute(1))
 ExampleAsyncIntCommandWithCanExecute.Execute(1);
 }
 finally
 {
 _isBusy = false;
 }
 }
}

AsyncValueCommand

Allows for ValueTask to safely be used asynchronously with ICommand.

If you're new to ValueTask, check out this great write-up, Understanding the Whys, Whats, and Whens of ValueTask.

  • AsyncValueCommand<TExecute, TCanExecute> : IAsyncValueCommand<TExecute, TCanExecute>
  • IAsyncValueCommand<TExecute, TCanExecute> : IAsyncValueCommand<TExecute>
  • AsyncValueCommand<T> : IAsyncValueCommand<T>
  • IAsyncValueCommand<T> : ICommand
  • AsyncValueCommand : IAsyncValueCommand
  • IAsyncValueCommand : ICommand
public AsyncValueCommand(Func<TExecute, ValueTask> execute,
 Func<TCanExecute, bool>? canExecute = null,
 Action<Exception>? onException = null,
 bool continueOnCapturedContext = false)
public AsyncValueCommand(Func<T, ValueTask> execute,
 Func<object?, bool>? canExecute = null,
 Action<Exception>? onException = null,
 bool continueOnCapturedContext = false)
public AsyncValueCommand(Func<ValueTask> execute,
 Func<object?, bool>? canExecute = null,
 Action<Exception>? onException = null,
 bool continueOnCapturedContext = false)
public class ExampleClass
{
 bool _isBusy;

 public ExampleClass()
 {
 ExampleValueTaskCommand = new AsyncValueCommand(ExampleValueTaskMethod);
 ExampleValueTaskIntCommand = new AsyncValueCommand<int>(ExampleValueTaskMethodWithIntParameter);
 ExampleValueTaskIntCommandWithCanExecute = new AsyncValueCommand<int, int>(ExampleValueTaskMethodWithIntParameter, CanExecuteInt);
 ExampleValueTaskExceptionCommand = new AsyncValueCommand(ExampleValueTaskMethodWithException, onException: ex => Debug.WriteLine(ex.ToString()));
 ExampleValueTaskCommandWithCanExecuteChanged = new AsyncValueCommand(ExampleValueTaskMethod, _ => !IsBusy);
 ExampleValueTaskCommandReturningToTheCallingThread = new AsyncValueCommand(ExampleValueTaskMethod, continueOnCapturedContext: true);
 }

 public IAsyncValueCommand ExampleValueTaskCommand { get; }
 public IAsyncValueCommand<int> ExampleValueTaskIntCommand { get; }
 public IAsyncCommand<int, int> ExampleValueTaskIntCommandWithCanExecute { get; }
 public IAsyncValueCommand ExampleValueTaskExceptionCommand { get; }
 public IAsyncValueCommand ExampleValueTaskCommandWithCanExecuteChanged { get; }
 public IAsyncValueCommand ExampleValueTaskCommandReturningToTheCallingThread { get; }

 public bool IsBusy
 {
 get => _isBusy;
 set
 {
 if (_isBusy != value)
 {
 _isBusy = value;
 ExampleValueTaskCommandWithCanExecuteChanged.RaiseCanExecuteChanged();
 }
 }
 }

 async ValueTask ExampleValueTaskMethod()
 {
 var random = new Random();
 if (random.Next(10) > 9)
 await Task.Delay(1000);
 }

 async ValueTask ExampleValueTaskMethodWithIntParameter(int parameter)
 {
 var random = new Random();
 if (random.Next(10) > 9)
 await Task.Delay(parameter);
 }

 async ValueTask ExampleValueTaskMethodWithException()
 {
 var random = new Random();
 if (random.Next(10) > 9)
 await Task.Delay(1000);

 throw new Exception();
 }

 bool CanExecuteInt(int count)
 {
 if(count > 2)
 return true;
 
 return false;
 }

 void ExecuteCommands()
 {
 _isBusy = true;

 try
 {
 ExampleValueTaskCommand.Execute(null);
 ExampleValueTaskIntCommand.Execute(1000);
 ExampleValueTaskExceptionCommand.Execute(null);
 ExampleValueTaskCommandReturningToTheCallingThread.Execute(null);

 if (ExampleValueTaskCommandWithCanExecuteChanged.CanExecute(null))
 ExampleValueTaskCommandWithCanExecuteChanged.Execute(null);

 if(ExampleValueTaskIntCommandWithCanExecute.CanExecute(2))
 ExampleValueTaskIntCommandWithCanExecute.Execute(2);
 }
 finally
 {
 _isBusy = false;
 }
 }
}
Product Versions Compatible and additional computed target framework versions.
.NET net5.0 net5.0 was computed.  net5.0-windows net5.0-windows was computed.  net6.0 net6.0 was computed.  net6.0-android net6.0-android was computed.  net6.0-ios net6.0-ios was computed.  net6.0-maccatalyst net6.0-maccatalyst was computed.  net6.0-macos net6.0-macos was computed.  net6.0-tvos net6.0-tvos was computed.  net6.0-windows net6.0-windows was computed.  net7.0 net7.0 was computed.  net7.0-android net7.0-android was computed.  net7.0-ios net7.0-ios was computed.  net7.0-maccatalyst net7.0-maccatalyst was computed.  net7.0-macos net7.0-macos was computed.  net7.0-tvos net7.0-tvos was computed.  net7.0-windows net7.0-windows was computed.  net8.0 net8.0 is compatible.  net8.0-android net8.0-android was computed.  net8.0-browser net8.0-browser was computed.  net8.0-ios net8.0-ios was computed.  net8.0-maccatalyst net8.0-maccatalyst was computed.  net8.0-macos net8.0-macos was computed.  net8.0-tvos net8.0-tvos was computed.  net8.0-windows net8.0-windows was computed.  net9.0 net9.0 is compatible.  net9.0-android net9.0-android was computed.  net9.0-browser net9.0-browser was computed.  net9.0-ios net9.0-ios was computed.  net9.0-maccatalyst net9.0-maccatalyst was computed.  net9.0-macos net9.0-macos was computed.  net9.0-tvos net9.0-tvos was computed.  net9.0-windows net9.0-windows was computed.  net10.0 net10.0 is compatible.  net10.0-android net10.0-android was computed.  net10.0-browser net10.0-browser was computed.  net10.0-ios net10.0-ios was computed.  net10.0-maccatalyst net10.0-maccatalyst was computed.  net10.0-macos net10.0-macos was computed.  net10.0-tvos net10.0-tvos was computed.  net10.0-windows net10.0-windows was computed. 
.NET Core netcoreapp1.0 netcoreapp1.0 was computed.  netcoreapp1.1 netcoreapp1.1 was computed.  netcoreapp2.0 netcoreapp2.0 was computed.  netcoreapp2.1 netcoreapp2.1 was computed.  netcoreapp2.2 netcoreapp2.2 was computed.  netcoreapp3.0 netcoreapp3.0 was computed.  netcoreapp3.1 netcoreapp3.1 was computed. 
.NET Standard netstandard1.0 netstandard1.0 is compatible.  netstandard1.1 netstandard1.1 was computed.  netstandard1.2 netstandard1.2 was computed.  netstandard1.3 netstandard1.3 was computed.  netstandard1.4 netstandard1.4 was computed.  netstandard1.5 netstandard1.5 was computed.  netstandard1.6 netstandard1.6 was computed.  netstandard2.0 netstandard2.0 is compatible.  netstandard2.1 netstandard2.1 is compatible. 
.NET Framework net45 net45 was computed.  net451 net451 was computed.  net452 net452 was computed.  net46 net46 was computed.  net461 net461 was computed.  net462 net462 was computed.  net463 net463 was computed.  net47 net47 was computed.  net471 net471 was computed.  net472 net472 was computed.  net48 net48 was computed.  net481 net481 was computed. 
MonoAndroid monoandroid monoandroid was computed. 
MonoMac monomac monomac was computed. 
MonoTouch monotouch monotouch was computed. 
Tizen tizen30 tizen30 was computed.  tizen40 tizen40 was computed.  tizen60 tizen60 was computed. 
Universal Windows Platform uap uap was computed.  uap10.0 uap10.0 was computed. 
Windows Phone wp8 wp8 was computed.  wp81 wp81 was computed.  wpa81 wpa81 was computed. 
Windows Store netcore netcore was computed.  netcore45 netcore45 was computed.  netcore451 netcore451 was computed. 
Xamarin.iOS xamarinios xamarinios was computed. 
Xamarin.Mac xamarinmac xamarinmac was computed. 
Xamarin.TVOS xamarintvos xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (10)

Showing the top 5 NuGet packages that depend on AsyncAwaitBestPractices.MVVM:

Package Downloads
Shinya.Core

Shinya.Framework

AwaitablePopups

Create your own DisplayAlerts using XAML, or use the DisplayAlerts,LoaderDialogs and LoginViews that's included! Powered by AsyncAwaitBestPractices and Rg.Plugins.Popup

Sanet.MVVM.Core

A simple MVVM helpers library to support my personal legacy projects

GuardedActions

Package Description

AppHosting.Xamarin.Forms

Provides attributes, controls, extensions methods, Xamarin.Forms page & element middlewares, services & utilities to setup your application infrastructure. Please, head to the project's repository for wiki.

GitHub repositories (12)

Showing the top 12 popular GitHub repositories that depend on AsyncAwaitBestPractices.MVVM:

Repository Stars
beeradmoore/dlss-swapper
yourtablecloth/TableCloth
식탁보 프로젝트
fernandreu/office-ribbonx-editor
An overhauled fork of the original Custom UI Editor for Microsoft Office, built with WPF
BAndysc/WoWDatabaseEditor
Integrated development environment (IDE), an editor for Smart Scripts (SAI/smart_scripts) for TrinityCore based servers. Cmangos support work in progress. Featuring a 3D view built with OpenGL and custom ECS framework
davidortinau/Xappy
A mobile app to track Xamarin news and explore all the goodness that is .NET for Mobile developers
LuckyDucko/Mopups
Popups For MAUI
Goz3rr/SatisfactorySaveEditor
xamarin/dev-days-labs
bitwarden/mobile
Retired Bitwarden mobile app for iOS and Android (MAUI/Xamarin).
MahApps/IconPacks.Browser
The Browser for all available Icon packages from MahApps.Metro.IconPacks
cyanlabs/Syn3Updater
Windows application for updating Ford Sync 3 infotainment systems
dorisoy/Dorisoy.SIOT
一款利用.NET 8.0和MAUI框架打造的跨平台牙科治疗机物联网移动端应用,实现了对水温Speedometer监测、高速手机转速RadialGauge显示、电动马达功率检测以及光纤灯光亮度调节等功能的数据采集与仪表盘实时展示,同时支持数据可视化检测和远程操控管理。
Version Downloads Last Updated
10.0.0 51,717 11/11/2025
9.0.0 144,826 11/15/2024
8.0.0 54,911 7/9/2024
7.0.0 77,423 11/14/2023
6.0.6 186,864 11/12/2022
6.0.5 20,147 7/3/2022
6.0.4 198,627 11/23/2021
6.0.3 7,132 11/11/2021
6.0.2 13,375 10/12/2021
6.0.1 10,679 9/27/2021
6.0.0 35,194 7/3/2021
6.0.0-pre1 1,430 6/7/2021
5.1.0 70,531 3/13/2021
5.0.2 118,186 11/2/2020
5.0.0-pre2 2,291 9/17/2020
5.0.0-pre1 1,171 9/17/2020
4.3.0 13,337 9/15/2020
4.3.0-pre1 2,332 7/29/2020
Loading failed

New in this release:
     - Add support for .NET 10