Replace the Async coordination primitives

This commit is contained in:
Sébastien Warin
2018-05-15 15:28:14 +02:00
parent 3e6edb92c5
commit 10740f12c4
7 changed files with 325 additions and 103 deletions
+2 -7
View File
@@ -21,22 +21,17 @@ namespace MQTTnet.Core.Tests
#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
threads[i] = Task.Run(async () =>
{
await @lock.EnterAsync(CancellationToken.None);
try
using (var releaser = await @lock.LockAsync(CancellationToken.None))
{
var localI = globalI;
await Task.Delay(10); // Increase the chance for wrong data.
localI++;
globalI = localI;
}
finally
{
@lock.Exit();
}
});
#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
}
Task.WaitAll(threads);
Assert.AreEqual(ThreadsCount, globalI);
}