public void CancelCurrent() { if (_current != null) { _current.Cancel(); } }
protected override void OnComplete() { if (isCancelled) { _coroutine.Cancel(); } }
public void release() { if (future != null) { future.Cancel(true); } }
/// <summary> /// Used to terminate the current task. /// </summary> public bool Cancel() { if (null != future) { return(future.Cancel(true)); } return(false); }
protected override void OnComplete() { if (isCancelled) { _delayFuture.Cancel(); } if (_timer != null) { _timer.Drop(); } }
public static Task <T> AsTask <T> (this IFuture future, CancellationToken token = default(CancellationToken)) where T : class, IJavaObject { var tcs = new TaskCompletionSource <T> (); future.SetCallback(new TaskFutureCallback <T> (tcs, future)); token.Register(() => { future.Cancel(); }); return(tcs.Task); }
public T Call() { IFuture <T> ftask = _exec.Submit(_func); try { return(ftask.GetResult(_duration)); } finally { ftask.Cancel(true); } }
protected override void OnComplete() { if (isCancelled) { if (currentFuture != null) { currentFuture.RemoveListener(Next); currentFuture.Cancel(); } } currentFuture = null; enumerator = null; }
public static Task <TResult?> AsTask <TResult>(this IFuture future, CancellationToken cancellationToken = default) where TResult : Java.Lang.Object { cancellationToken.Register(() => future.Cancel(true)); return(Task.Run(() => { try { var obj = future.Get(); if (future.IsCancelled || cancellationToken.IsCancellationRequested) { throw new OperationCanceledException(); } return (TResult?)obj; } catch (CancellationException) { throw new OperationCanceledException(); } })); }