Skip to content

Commit 4589b01

Browse files
committed
Fix some TCS
1 parent c9a44af commit 4589b01

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

lib/PuppeteerSharp/Bidi/BidiFrame.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ async Task<Navigation> WaitForEventNavigationAsync()
114114
var navigationTcs = new TaskCompletionSource<Navigation>(TaskCreationOptions.RunContinuationsAsynchronously);
115115

116116
// TODO: Async void is not safe. Refactor code.
117-
BrowsingContext.Navigation += (sender, args) => navigationTcs.SetResult(args.Navigation);
117+
BrowsingContext.Navigation += (sender, args) => navigationTcs.TrySetResult(args.Navigation);
118118

119119
await navigationTcs.Task.ConfigureAwait(false);
120120

@@ -182,14 +182,14 @@ private Task WaitForLoadAsync(NavigationOptions options)
182182
if (waitUntil.Contains(WaitUntilNavigation.Load))
183183
{
184184
var loadTcs = new TaskCompletionSource<bool>();
185-
BrowsingContext.Load += (sender, args) => loadTcs.SetResult(true);
185+
BrowsingContext.Load += (sender, args) => loadTcs.TrySetResult(true);
186186
tasks.Add(loadTcs.Task);
187187
}
188188

189189
if (waitUntil.Contains(WaitUntilNavigation.DOMContentLoaded))
190190
{
191191
var domContentLoadedTcs = new TaskCompletionSource<bool>();
192-
BrowsingContext.DomContentLoaded += (sender, args) => domContentLoadedTcs.SetResult(true);
192+
BrowsingContext.DomContentLoaded += (sender, args) => domContentLoadedTcs.TrySetResult(true);
193193
tasks.Add(domContentLoadedTcs.Task);
194194
}
195195

0 commit comments

Comments
 (0)