public void Stop() { if (timeoutHandle != null) { Jsni.clearTimeout(timeoutHandle); timeoutHandle = null; } if (intervalHandle != null) { Jsni.clearInterval(intervalHandle); intervalHandle = null; } }
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); }