Skip to content

Commit cf97324

Browse files
committed
Offscreen Example - Add comment about TrySetResultAsync
1 parent 14b5095 commit cf97324

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

CefSharp.OffScreen.Example/Program.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,8 @@ await Cef.UIThreadTaskFactory.StartNew(delegate
105105

106106
public static Task LoadPageAsync(IWebBrowser browser, string address = null)
107107
{
108+
//If using .Net 4.6 then use TaskCreationOptions.RunContinuationsAsynchronously
109+
//and switch to tcs.TrySetResult below - no need for the custom extension method
108110
var tcs = new TaskCompletionSource<bool>();
109111

110112
EventHandler<LoadingStateChangedEventArgs> handler = null;
@@ -114,6 +116,8 @@ public static Task LoadPageAsync(IWebBrowser browser, string address = null)
114116
if (!args.IsLoading)
115117
{
116118
browser.LoadingStateChanged -= handler;
119+
//This is required when using a standard TaskCompletionSource
120+
//Extension method found in the CefSharp.Internals namespace
117121
tcs.TrySetResultAsync(true);
118122
}
119123
};

0 commit comments

Comments
 (0)