CoCoL 1.8.0

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

// Install CoCoL as a Cake Tool
#tool nuget:?package=CoCoL&version=1.8.0

CoCoL is a fresh multi-programming approach, leveraging the C# await keyword to produce sequential and easily understandable multithreading code. With a shared-nothing approach and explicit communication, programs written with CoCoL are automatically free from race conditions and other threading hazards.

If you are familiar with the Go Language, you can think of CoCoL as providing the Go programming model inside the CLR.

Hello World

The most basic program with multithreading would be a producer/consumer setup, where one thread produces data, and another consumes it:

using CoCoL;

class Example
{
    static async Task Produce(IChannel<int> channel)
    {
        foreach (var i in Enumerable.Range(0, 5))
            await channel.WriteAsync(i);
        channel.Retire();
    }

    static async Task Consume(IChannel<int> channel)
    {
        try
        {
            while (true)
                Console.WriteLine("Hello World: {0}", await channel.ReadAsync());
        }
        catch (RetiredException)
        {
        }
    }

    static void Main()
    {
        var channel = ChannelManager.CreateChannel<int>();
        Task.WhenAll(
          Produce(channel),
          Consume(channel)
        ).Wait();
    }
}

Output:

Hello World: 0
Hello World: 1
Hello World: 2
Hello World: 3
Hello World: 4
Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net8.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories (1)

Showing the top 1 popular GitHub repositories that depend on CoCoL:

Repository Stars
duplicati/duplicati
Store securely encrypted backups in the cloud!
Version Downloads Last updated
1.8.0 27 5/30/2024
1.7.1 24,478 9/20/2019
1.7.0 1,596 9/10/2019
1.6.2 2,197 9/3/2019
1.6.1 5,478 4/13/2018
1.6.0 1,189 1/23/2018
1.5.1 31,560 9/20/2017
1.5.0 6,440 4/10/2016
1.4.9 1,092 4/8/2016
1.4.7 1,092 4/6/2016
1.4.6 1,080 4/1/2016
1.4.5 1,085 4/1/2016
1.4.1 1,123 3/17/2016
1.4.0 1,219 2/20/2016
1.3.1 1,149 12/23/2015
1.3.0 1,152 12/22/2015
1.2.2 1,120 12/21/2015
1.2.1 1,139 12/20/2015
1.2.0 1,114 12/19/2015
1.1.0 1,134 12/17/2015
1.0.0 1,294 6/10/2015

Updated to .NET8.