mirror of
https://github.com/cefsharp/CefSharp.git
synced 2026-12-04 08:34:55 +00:00
1524482ede
- 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
35 lines
1.1 KiB
C#
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);
|
|
}
|
|
}
|
|
}
|