mirror of
https://github.com/cefsharp/CefSharp.git
synced 2026-12-04 10:22:55 +00:00
60ae3cc739
Invoke TrySetResult using TaskFactory.Run so continuations are run in an async fashion Reference #1672
30 lines
751 B
C#
30 lines
751 B
C#
// Copyright © 2010-2016 The CefSharp Project. 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;
|
|
using CefSharp.Internals;
|
|
|
|
namespace CefSharp
|
|
{
|
|
public class TaskCompletionHandler : ICompletionCallback
|
|
{
|
|
private readonly TaskCompletionSource<bool> taskCompletionSource;
|
|
|
|
public TaskCompletionHandler()
|
|
{
|
|
taskCompletionSource = new TaskCompletionSource<bool>();
|
|
}
|
|
|
|
public void OnComplete()
|
|
{
|
|
taskCompletionSource.TrySetResultAsync(true);
|
|
}
|
|
|
|
public Task<bool> Task
|
|
{
|
|
get { return taskCompletionSource.Task; }
|
|
}
|
|
}
|
|
}
|