Skip to content

Instantly share code, notes, and snippets.

@TakaakiIchijo
Last active August 8, 2019 05:06
Show Gist options
  • Save TakaakiIchijo/8fb835821432f3390278d3d316cb7c83 to your computer and use it in GitHub Desktop.
Save TakaakiIchijo/8fb835821432f3390278d3d316cb7c83 to your computer and use it in GitHub Desktop.
ADX2AddCueSheetToTaskID
using System.Threading;
using System.Threading.Tasks;
public static class ADX2AddCueSheetToTask
{
public static Task<CriAtomCueSheet> ToTask(this CriAtomCueSheet cueSheet, CancellationToken ct)
{
var tcs = new TaskCompletionSource<CriAtomCueSheet>();
if (ct != CancellationToken.None)
{
ct.Register(() => tcs.TrySetCanceled(ct));
}
Task.Run(() =>
{
while (cueSheet.loaderStatus == CriAtomExAcbLoader.Status.Loading)
{
Task.Yield();
}
tcs.TrySetResult(cueSheet);
}, ct);
return tcs.Task;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment