Marathon 1.0.0

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

// Install Marathon as a Cake Tool
#tool nuget:?package=Marathon&version=1.0.0                

Marathon

The Marathon library provides a .NET, cross-platform, lightweight task running library. It facilitates the composition of tasks for sequential and parallel execution, or both. Further, it provides synchronous and asynchronous implementations of the composed tasks in a transparent manner to the user.

Leveraging the Task Parallel Library is even easier, clearer, and more expressive when using Marathon.

Compatibility

  • .NET Standard 2.1

Installation

  • NuGet: coming soon!

Hello World

// Create some Actions to execute.
Action hello = delegate { Console.Write("Hello, "); }
Action world = delegate { Console.Write("world"); }
Action emphasis = delegate { Console.Write("!"); }
Action nl = delegate { Console.WriteLine(); }
// The 'Runner' class builds and runs tasks from the given Actions.
Runner runner = new Runner();  
runner.Run(hello)     // `Run()` starts building and running the given delegates.
      .Then(world)    // `Then()` waits for the previous Task to finish before starting.
      .Then(emphasis)
      .And(emphasis)  // `And()` starts running the given delegate at the same time as the previous one.
      .And(emphasis)
      .Then(nl)
      .Sync();        // `Sync()` waits for all the tasks to finish, blocking the current thread.

Output:

> Hello, world!!!
>

In-Depth

Marathon tasks are built starting with the Runner class. As the only class that implements the IRun interface, it exposes the Run() method which starts the scheduling of Actions as tasks to be run. The Run() method returns a BaseRunner which exposes the two run types in Marathon, And and Then.

Ands are the implementation of the IAnd interface and tell the scheduler that the given Action should be run in parallel as the previous Action. These can be chained as many times as desired. For example, BaseRunner tasks = runner.Run(action1).And(action2).And(action3) would build tasks to run action1, action2, and action3 at the same time once either the Sync() or Async() method is invoked.

Thens are the implementation of the IThen interface and tell the scheduler that the given Action should only be run after the previous Action has finished. These can be chained as many times as desired. For example, BaseRunner tasks = runner.Run(action1).Then(action2).Then(action3) would build tasks to run action1, then action2, and finally action3 once either the Sync() or Async() method is invoked.

Lastly, the crème de la crème that makes Marathon special: the ability to transparently execute the scheduled tasks synchronously or asynchronously. This is possible because the BaseRunner class implements the ISync and IAsync interfaces. These two interfaces expose the Sync() and Async() methods, respectively, and end the chain of a Runner's tasks. The Sync() method schedules the tasks to be executed synchronously, blocking the current thread. Alternatively, the Async() method schedules the tasks to be executed asynchronously, just how you'd expect normal async methods in .NET to work.

Examples

See here in the wiki.

Changes

  • Added examples to wiki.
  • Updated README file.
  • Tentatively finished initial pre-release.
Product 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 netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.1

    • No dependencies.

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
1.0.0 554 12/14/2019

1.0.0 - Initial release.