Ejemplo n.º 1
0
        public static IObservable <T> DelayFrame <T>(this IObservable <T> source, int frameCount, FrameCountType frameCountType = FrameCountType.Update)
        {
            if (frameCount < 0)
            {
                throw new ArgumentOutOfRangeException("frameCount");
            }

            return(Observable.Create <T>(observer =>
            {
                var cancel = new BooleanDisposable();

                source.Materialize().Subscribe(x =>
                {
                    if (x.Kind == NotificationKind.OnError)
                    {
                        observer.OnError(x.Exception);
                        cancel.Dispose();
                        return;
                    }

                    UnityMainThreadDispatcher.StartCoroutine(DelayFrameCore(() => x.Accept(observer), frameCount, frameCountType, cancel));
                });

                return cancel;
            }));
        }
Ejemplo n.º 2
0
 public void Cancel()
 {
     if (Status == TaskStatus.WaitingToRun || Status == TaskStatus.Running)
     {
         Status = TaskStatus.Canceled;
         cancellation.Dispose();
     }
 }