Last active
August 8, 2019 05:06
-
-
Save TakaakiIchijo/8fb835821432f3390278d3d316cb7c83 to your computer and use it in GitHub Desktop.
ADX2AddCueSheetToTaskID
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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