mirror of
https://github.com/OPCFoundation/UA-.NETStandard.git
synced 2026-10-16 21:02:51 +08:00
Wait for the spawner work item in the G5 regression test
Background work items can run concurrently, so the test could read the disposal task before the spawner item assigned it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -127,17 +127,19 @@ namespace Opc.Ua.Client.Tests.AuditRegressions
|
||||
var trigger = new TaskCompletionSource<bool>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
using var otherRunning = new ManualResetEventSlim(false);
|
||||
using var releaseOther = new ManualResetEventSlim(false);
|
||||
Task disposal = null;
|
||||
var spawned = new TaskCompletionSource<Task>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
|
||||
Assert.That(session.RunBackgroundWork("spawner", () =>
|
||||
{
|
||||
// Captures the execution context of the work item.
|
||||
disposal = trigger.Task.ContinueWith(
|
||||
spawned.SetResult(trigger.Task.ContinueWith(
|
||||
_ => session.Dispose(),
|
||||
CancellationToken.None,
|
||||
TaskContinuationOptions.None,
|
||||
TaskScheduler.Default);
|
||||
TaskScheduler.Default));
|
||||
}), Is.True);
|
||||
// Background work items may run concurrently; wait until the spawner ran.
|
||||
Task disposal = await spawned.Task.WaitAsync(TimeSpan.FromSeconds(10)).ConfigureAwait(false);
|
||||
Assert.That(session.RunBackgroundWork("other", () =>
|
||||
{
|
||||
otherRunning.Set();
|
||||
|
||||
Reference in New Issue
Block a user