mirror of
https://github.com/microsoft/agent-framework.git
synced 2026-06-16 21:04:09 +08:00
.NET: Clean up some CancellationToken usage (#996)
* Clean up some CancellationToken usage * Unused usings
This commit is contained in:
@@ -68,7 +68,7 @@ public class RepresentationTests
|
||||
testsRun++;
|
||||
}
|
||||
|
||||
async ValueTask MessageHandlerAsync(int message, IWorkflowContext workflowContext, CancellationToken cancellation = default)
|
||||
async ValueTask MessageHandlerAsync(int message, IWorkflowContext workflowContext, CancellationToken cancellationToken = default)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -113,12 +113,12 @@ internal sealed class JudgeExecutor : ReflectingExecutor<JudgeExecutor>, IMessag
|
||||
NumberSignal.Above;
|
||||
}
|
||||
|
||||
protected internal override ValueTask OnCheckpointingAsync(IWorkflowContext context, CancellationToken cancellation = default)
|
||||
protected internal override ValueTask OnCheckpointingAsync(IWorkflowContext context, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return context.QueueStateUpdateAsync("TryCount", this.Tries);
|
||||
}
|
||||
|
||||
protected internal override async ValueTask OnCheckpointRestoredAsync(IWorkflowContext context, CancellationToken cancellation = default)
|
||||
protected internal override async ValueTask OnCheckpointRestoredAsync(IWorkflowContext context, CancellationToken cancellationToken = default)
|
||||
{
|
||||
this.Tries = await context.ReadStateAsync<int?>("TryCount").ConfigureAwait(false) ?? 0;
|
||||
}
|
||||
|
||||
+1
-1
@@ -41,7 +41,7 @@ internal static class Step5EntryPoint
|
||||
{
|
||||
await handle.EndRunAsync().ConfigureAwait(false);
|
||||
|
||||
checkpointed = await InProcessExecution.ResumeStreamAsync(workflow, targetCheckpoint, checkpointManager, runId: handle.RunId, cancellation: CancellationToken.None)
|
||||
checkpointed = await InProcessExecution.ResumeStreamAsync(workflow, targetCheckpoint, checkpointManager, runId: handle.RunId, cancellationToken: CancellationToken.None)
|
||||
.ConfigureAwait(false);
|
||||
handle = checkpointed.Run;
|
||||
}
|
||||
|
||||
@@ -25,12 +25,12 @@ internal abstract class TestingExecutor<TIn, TOut> : Executor, IDisposable
|
||||
this._actions = actions;
|
||||
}
|
||||
|
||||
public void UnlinkCancellation(CancellationToken token) =>
|
||||
this._linkedTokens.Remove(token);
|
||||
public void UnlinkCancellation(CancellationToken cancellationToken) =>
|
||||
this._linkedTokens.Remove(cancellationToken);
|
||||
|
||||
public void LinkCancellation(CancellationToken token)
|
||||
public void LinkCancellation(CancellationToken cancellationToken)
|
||||
{
|
||||
this._linkedTokens.Add(token);
|
||||
this._linkedTokens.Add(cancellationToken);
|
||||
CancellationTokenSource tokenSource = CancellationTokenSource.CreateLinkedTokenSource(this._linkedTokens.ToArray());
|
||||
tokenSource = Interlocked.Exchange(ref this._internalCts, tokenSource);
|
||||
tokenSource.Dispose();
|
||||
|
||||
Reference in New Issue
Block a user