Created
November 26, 2019 07:59
-
-
Save TakaakiIchijo/2da53fbe2c3d2dd168c64ef157aac0a5 to your computer and use it in GitHub Desktop.
ADX2のキューシートロードをasync/awaitで呼ぶやつ
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
public static class ADX2ExtensionsTask | |
{ | |
public static Task<CriAtomCueSheet> ToTask(this CriAtomCueSheet cueSheet, CancellationToken ct = default) | |
{ | |
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; | |
} | |
public static async Task<CriAtomCueSheet> AddCueSheetAcbTask(this CriAtom atom, string cueSheetName, string path) | |
{ | |
return await CriAtom.AddCueSheetAsync(cueSheetName, path, "").ToTask(CancellationToken.None); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment