SHARE
TWEET

Untitled

a guest Aug 20th, 2019 60 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System.Threading;
  2. using System.Threading.Tasks;
  3.  
  4. public static class ADX2AddCueSheetToTask
  5. {
  6.     public static Task<CriAtomCueSheet> ToTask(this CriAtomCueSheet cueSheet, CancellationToken ct)
  7.     {
  8.         var tcs = new TaskCompletionSource<CriAtomCueSheet>();
  9.        
  10.         if (ct != CancellationToken.None)
  11.         {
  12.             ct.Register(() => tcs.TrySetCanceled(ct));
  13.         }
  14.  
  15.         Task.Run(() =>
  16.         {
  17.             while (cueSheet.loaderStatus == CriAtomExAcbLoader.Status.Loading)
  18.             {
  19.                 Task.Yield();
  20.             }
  21.             tcs.TrySetResult(cueSheet);
  22.            
  23.         }, ct);
  24.  
  25.         return tcs.Task;
  26.     }
  27. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top