mirror of
https://github.com/dotnet/MQTTnet.git
synced 2026-10-20 19:58:57 +08:00
Fix memory leak in AsyncAutoResetEvent.
This commit is contained in:
committed by
Christian Kratky
parent
4fed80c2d0
commit
5090cfb411
@@ -17,6 +17,31 @@ namespace MQTTnet.Core.Tests
|
||||
_aare = new AsyncAutoResetEvent();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public async Task Cleanup_Waiters()
|
||||
{
|
||||
var @lock = new AsyncAutoResetEvent();
|
||||
|
||||
var waitOnePassed = false;
|
||||
|
||||
Task.Run(async () =>
|
||||
{
|
||||
await @lock.WaitOneAsync(TimeSpan.FromSeconds(2));
|
||||
waitOnePassed = true;
|
||||
});
|
||||
|
||||
await Task.Delay(500);
|
||||
|
||||
Assert.AreEqual(1, @lock.WaitersCount);
|
||||
|
||||
@lock.Set();
|
||||
|
||||
await Task.Delay(1000);
|
||||
|
||||
Assert.IsTrue(waitOnePassed);
|
||||
Assert.AreEqual(0, @lock.WaitersCount);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public async Task SingleThreadedPulse()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user