Starcounter.Async 3.0.0

dotnet add package Starcounter.Async --version 3.0.0
NuGet\Install-Package Starcounter.Async -Version 3.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="Starcounter.Async" Version="3.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Starcounter.Async --version 3.0.0
#r "nuget: Starcounter.Async, 3.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.
// Install Starcounter.Async as a Cake Addin
#addin nuget:?package=Starcounter.Async&version=3.0.0

// Install Starcounter.Async as a Cake Tool
#tool nuget:?package=Starcounter.Async&version=3.0.0

Starcounter Async Extensions

Available on nuget: Install-Package Starcounter.Async -Version 1.0.0

To introduce asynchronicity in Starcounter TypedJSON view-model, you have to use callbacks and handle errors carefully:

public void Handle(Input.StartWorkTrigger input)
{
    this.IsBusy = true;
    Task.Run(LengthyJob)
        .ContinueWith(task => Session.ScheduleTask(Session.Current.SessionId,
        (Session session, string sessionId) => {
            // might happen if this code is executed after the session has been destroyed
            if (session == null)
            {
                return;
            }
            try
            {
                // if LengthyJob resulted in exception, it will be unwrapped here
                this.Result = task.Result;
            }
            catch (Exception e)
            {
                this.Result = "Error";
            }
            finally
            {
                this.IsBusy = false;
                // otherwise the changes won't be immediately visible to the client
                session.CalculatePatchAndPushOnWebSocket();
            }
        }));
}

This library allows you to simplify this code by using async-await

public void Handle(Input.StartWorkTrigger input)
{
    AsyncInputHandlers.Run(async () =>
    {
        this.IsBusy = true;
        try
        {
            this.Result = await LengthyJob();
        }
        catch(Exception e)
        {
            this.Result = "Error";
        }
        finally
        {
            this.IsBusy = false;
        }
    });
}
Product Compatible and additional computed target framework versions.
.NET Framework net461 is compatible.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
3.0.0 615 3/19/2019

Compatibility with 2.4, for 2.3-compatible version please use 1.0.0 of this package