Пример #1
0
 public void Stop()
 {
     if (timeoutHandle != null)
     {
         Jsni.clearTimeout(timeoutHandle);
         timeoutHandle = null;
     }
     if (intervalHandle != null)
     {
         Jsni.clearInterval(intervalHandle);
         intervalHandle = null;
     }
 }
Пример #2
0
        public static Task Delay(int millisecondsDelay, CancellationToken cancellationToken)
        {
            var completionSource = new TaskCompletionSource <object>();
            var token            = Jsni.setTimeout(
                () =>
            {
                completionSource.SetResult(null);
            },
                millisecondsDelay);

            cancellationToken.Register(() =>
            {
                Jsni.clearTimeout(token);
                completionSource.TrySetCanceled(cancellationToken);
            });
            return(completionSource.Task);
        }