public IPipeContextAgent <SimpleContext> CreateContext(ISupervisor supervisor) { var context = new SimpleContextImpl() { Value = Interlocked.Increment(ref _id).ToString() }; IPipeContextAgent <SimpleContext> contextHandle = supervisor.AddContext <SimpleContext>(context); void SimpleContextOnInvalid(object sender, EventArgs args) => contextHandle.DisposeAsync(); context.OnInvalid += SimpleContextOnInvalid; return(contextHandle); }
ValueTask IAsyncDisposable.DisposeAsync() { return(_agent.DisposeAsync()); }
Task IAsyncDisposable.DisposeAsync(CancellationToken cancellationToken) { return(_agent.DisposeAsync(cancellationToken)); }