mirror of
https://github.com/cefsharp/CefSharp.git
synced 2026-12-04 19:25:01 +00:00
Offscreen Example - Add comment about TrySetResultAsync
This commit is contained in:
@@ -105,6 +105,8 @@ namespace CefSharp.OffScreen.Example
|
||||
|
||||
public static Task LoadPageAsync(IWebBrowser browser, string address = null)
|
||||
{
|
||||
//If using .Net 4.6 then use TaskCreationOptions.RunContinuationsAsynchronously
|
||||
//and switch to tcs.TrySetResult below - no need for the custom extension method
|
||||
var tcs = new TaskCompletionSource<bool>();
|
||||
|
||||
EventHandler<LoadingStateChangedEventArgs> handler = null;
|
||||
@@ -114,6 +116,8 @@ namespace CefSharp.OffScreen.Example
|
||||
if (!args.IsLoading)
|
||||
{
|
||||
browser.LoadingStateChanged -= handler;
|
||||
//This is required when using a standard TaskCompletionSource
|
||||
//Extension method found in the CefSharp.Internals namespace
|
||||
tcs.TrySetResultAsync(true);
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user