cathode icon indicating copy to clipboard operation
cathode copied to clipboard

Offer `CancellationToken` support in `IProgram` (.NET 7)

Open alexrp opened this issue 3 years ago • 1 comments

Depends on:

  • [x] #103

Something like:

public interface IProgram
{
    public static virtual bool SupportsCancellation => true;

    public static abstract Task RunAsync(ProgramContext context);
}

If SupportsCancellation is true, ProgramHost will wire up a Signaled event handler to trigger a CancellationTokenSource whose CancellationToken gets passed as a property on ProgramContext.

(The reason for making cancellation support optional is that wiring up Signaled has side effects that may not be tolerable - see #64.)

alexrp avatar May 22 '22 15:05 alexrp

This can only happen in .NET 7 as the Roslyn shipped with .NET 6 does not support static virtual members.

alexrp avatar Jul 07 '22 21:07 alexrp