public void CancelCurrent()
 {
     if (_current != null)
     {
         _current.Cancel();
     }
 }
Exemple #2
0
 protected override void OnComplete()
 {
     if (isCancelled)
     {
         _coroutine.Cancel();
     }
 }
Exemple #3
0
 public void release()
 {
     if (future != null)
     {
         future.Cancel(true);
     }
 }
Exemple #4
0
        /// <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();
            }
        }
Exemple #6
0
        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);
        }
Exemple #7
0
            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();
                }
            }));
        }