Files
cefsharp/CefSharp/Internals/InitializeAsyncBrowserProcessHandler.cs
T
Alex Maitland 1524482ede Core - Add Cef.InitializeAsync
- InitializeAsyncBrowserProcessHandler is used to complete the taskCompletionSource
  when OnContextInitialized is called
- Update the OffScreen example to be async with a simply SingleThreadSynchronizationContext
  to ensure we continue on our main thread.

Issue #3634
2021-10-22 20:10:38 +10:00

35 lines
1.1 KiB
C#

// Copyright © 2021 The CefSharp Authors. All rights reserved.
//
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
using System.Threading.Tasks;
namespace CefSharp.Internals
{
/// <summary>
/// BrowserProcessHandler implementation that takes a <see cref="TaskCompletionSource{bool}"/>
/// and resolves when <see cref="OnContextInitialized"/> is called.
/// </summary>
public class InitializeAsyncBrowserProcessHandler : CefSharp.Handler.BrowserProcessHandler
{
private TaskCompletionSource<bool> taskCompletionSource;
/// <summary>
/// Default constructor
/// </summary>
/// <param name="tcs">task complection source</param>
public InitializeAsyncBrowserProcessHandler(TaskCompletionSource<bool> tcs)
{
taskCompletionSource = tcs;
}
/// <inheritdoc/>
protected override void OnContextInitialized()
{
base.OnContextInitialized();
taskCompletionSource.TrySetResult(true);
}
}
}