Refactor WaitForEventAsync to ForEventAsync

This commit is contained in:
Stone_Red
2026-10-20 16:36:02 +02:00
parent fcc33fd379
commit 566e3c42e8
2 changed files with 3 additions and 3 deletions
+2 -2
View File
@@ -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));
}); });
} }
+1 -1
View File
@@ -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();