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)
{
while (true)
{
await Task.Delay(50, ct);
_counter++;
}
}
public static async Task<uint> RunLongValue(uint x, CancellationToken ct)
{
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)
{
while (true)
{
await Task.Delay(50, ct);
_counter++;
}
}
public async Task<uint> RunLongValue(uint x, CancellationToken ct)
{
uint acc = 0;
while (true)
{
await Task.Delay(50, ct);
acc += x;
}
}
public uint Get() => _counter;
}