interoptopus_csharp 0.16.0-alpha.20

The C# backend for Interoptopus.
Documentation
// Auto-generated plugin interop
// <auto-generated/>

using System.ComponentModel;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.InteropServices.Marshalling;
using My.Company.Common;
using Interoptopus.API;


namespace My.Company;

partial class Plugin : IPlugin
{
    private static uint _counter;

    public static uint Get() => _counter;

    public static async Task RunLong(CancellationToken ct)
    {
        // Runs indefinitely — must be cancelled to complete
        while (true)
        {
            await Task.Delay(50, ct);
            _counter++;
        }
    }

    public static async Task<uint> RunLongValue(uint x, CancellationToken ct)
    {
        // Runs indefinitely — must be cancelled to complete
        uint acc = 0;
        while (true)
        {
            await Task.Delay(50, ct);
            acc += x;
        }
    }
}

partial class AsyncCancellation : IAsyncCancellation<AsyncCancellation>
{
    private uint _counter;

    public static Task<AsyncCancellation> Create(CancellationToken ct)
    {
        return Task.FromResult(new AsyncCancellation());
    }

    public async Task RunLong(CancellationToken ct)
    {
        // Runs indefinitely — must be cancelled to complete
        while (true)
        {
            await Task.Delay(50, ct);
            _counter++;
        }
    }

    public async Task<uint> RunLongValue(uint x, CancellationToken ct)
    {
        // Runs indefinitely — must be cancelled to complete
        uint acc = 0;
        while (true)
        {
            await Task.Delay(50, ct);
            acc += x;
        }
    }

    public uint Get() => _counter;
}