mirror of
https://github.com/Stone-Red-Code/CuteUtils.git
synced 2026-11-01 23:04:01 +01:00
Refactor WaitForEventAsync to ForEventAsync
This commit is contained in:
@@ -60,7 +60,7 @@ public class WaitTests
|
|||||||
handler();
|
handler();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
await Wait.WaitForEventAsync(subscribe, TimeSpan.FromSeconds(2));
|
await Wait.ForEventAsync(subscribe, TimeSpan.FromSeconds(2));
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
@@ -72,7 +72,7 @@ public class WaitTests
|
|||||||
}
|
}
|
||||||
_ = await Assert.ThrowsExactlyAsync<TimeoutException>(async () =>
|
_ = await Assert.ThrowsExactlyAsync<TimeoutException>(async () =>
|
||||||
{
|
{
|
||||||
await Wait.WaitForEventAsync(subscribe, TimeSpan.FromMilliseconds(200));
|
await Wait.ForEventAsync(subscribe, TimeSpan.FromMilliseconds(200));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ public static class Wait
|
|||||||
/// <param name="subscribe">An action that subscribes a handler to the event.</param>
|
/// <param name="subscribe">An action that subscribes a handler to the event.</param>
|
||||||
/// <param name="timeout">The maximum time to wait. Defaults to infinite.</param>
|
/// <param name="timeout">The maximum time to wait. Defaults to infinite.</param>
|
||||||
/// <exception cref="TimeoutException">Thrown if the event is not raised within the timeout.</exception>
|
/// <exception cref="TimeoutException">Thrown if the event is not raised within the timeout.</exception>
|
||||||
public static async Task WaitForEventAsync(Action<Action> subscribe, TimeSpan? timeout = null)
|
public static async Task ForEventAsync(Action<Action> subscribe, TimeSpan? timeout = null)
|
||||||
{
|
{
|
||||||
timeout ??= TimeSpan.MaxValue;
|
timeout ??= TimeSpan.MaxValue;
|
||||||
TaskCompletionSource tcs = new TaskCompletionSource();
|
TaskCompletionSource tcs = new TaskCompletionSource();
|
||||||
|
|||||||
Reference in New Issue
Block a user