using System; using System.Threading.Tasks; namespace Wabbajack.Common.CSP { class PutTaskHandler : Handler> { private readonly bool _blockable; private TaskCompletionSource _tcs = new TaskCompletionSource(); public PutTaskHandler(bool blockable = true) { _blockable = blockable; } public TaskCompletionSource TaskCompletionSource { get { if (_tcs == null) _tcs = new TaskCompletionSource(); return _tcs; } } public bool IsActive => true; public bool IsBlockable => _blockable; public uint LockId => 0; public Action Commit() { return Handle; } private void Handle(bool val) { TaskCompletionSource.SetResult(val); } } }