コード例 #1
0
        public static ETTask FromException(Exception ex)
        {
            ETTaskCompletionSource tcs = new ETTaskCompletionSource();

            tcs.TrySetException(ex);
            return(tcs.Task);
        }
コード例 #2
0
        public static ETTask <T> FromCanceled <T>(CancellationToken token)
        {
            var tcs = new ETTaskCompletionSource <T>();

            tcs.TrySetException(new OperationCanceledException(token));
            return(tcs.Task);
        }
コード例 #3
0
            static CanceledETTaskCache()
            {
                ETTaskCompletionSource tcs = new ETTaskCompletionSource();

                tcs.TrySetCanceled();
                Task = tcs.Task;
            }
コード例 #4
0
        public void Run()
        {
            ETTaskCompletionSource tcs = this.Callback;

            this.GetParent <TimerComponent>().Remove(this.Id);
            tcs.SetResult();
        }
コード例 #5
0
        public static ETTask <T> FromException <T>(Exception ex)
        {
            var tcs = new ETTaskCompletionSource <T>();

            tcs.TrySetException(ex);
            return(tcs.Task);
        }
コード例 #6
0
        public ETTask WaitAsync(long time)
        {
            long tillTime = TimeHelper.Now() + time;
            ETTaskCompletionSource tcs   = new ETTaskCompletionSource();
            OnceWaitTimer          timer = EntityFactory.CreateWithParent <OnceWaitTimer, ETTaskCompletionSource>(this, tcs);

            this.timers[timer.Id] = timer;
            AddToTimeId(tillTime, timer.Id);
            return(tcs.Task);
        }
コード例 #7
0
        public void Update()
        {
            if (!this.request.isDone)
            {
                return;
            }

            ETTaskCompletionSource t = tcs;

            t.SetResult();
        }
コード例 #8
0
        public ETTask DownloadAsync(string url)
        {
            this.tcs = new ETTaskCompletionSource();

            url          = url.Replace(" ", "%20");
            this.Request = UnityWebRequest.Get(url);
            this.Request.certificateHandler = certificateHandler;
            this.Request.SendWebRequest();

            return(this.tcs.Task);
        }
コード例 #9
0
        public void Update()
        {
            if (!this.request.isDone)
            {
                return;
            }

            ETTaskCompletionSource <AssetBundle> t = tcs;

            t.SetResult(this.request.assetBundle);
        }
コード例 #10
0
        public ETTask WaitTillAsync(long tillTime, ETCancellationToken cancellationToken)
        {
            if (TimeHelper.Now() > tillTime)
            {
                return(ETTask.CompletedTask);
            }
            ETTaskCompletionSource tcs   = new ETTaskCompletionSource();
            OnceWaitTimer          timer = EntityFactory.CreateWithParent <OnceWaitTimer, ETTaskCompletionSource>(this, tcs);

            this.timers[timer.Id] = timer;
            AddToTimeId(tillTime, timer.Id);
            cancellationToken.Register(() => { this.Remove(timer.Id); });
            return(tcs.Task);
        }
コード例 #11
0
        public void SetResult()
        {
            if (moveNext == null)
            {
            }
            else
            {
                if (this.tcs == null)
                {
                    this.tcs = new ETTaskCompletionSource();
                }

                this.tcs.TrySetResult();
            }
        }
コード例 #12
0
        public void SetException(Exception exception)
        {
            if (this.tcs == null)
            {
                this.tcs = new ETTaskCompletionSource();
            }

            if (exception is OperationCanceledException ex)
            {
                this.tcs.TrySetCanceled(ex);
            }
            else
            {
                this.tcs.TrySetException(exception);
            }
        }
コード例 #13
0
        public void SetResult(T ret)
        {
            if (moveNext == null)
            {
                this.result = ret;
            }
            else
            {
                if (this.tcs == null)
                {
                    this.tcs = new ETTaskCompletionSource <T>();
                }

                this.tcs.TrySetResult(ret);
            }
        }
コード例 #14
0
        public void AwaitOnCompleted <TAwaiter, TStateMachine>(ref TAwaiter awaiter, ref TStateMachine stateMachine)
            where TAwaiter : INotifyCompletion
            where TStateMachine : IAsyncStateMachine
        {
            if (moveNext == null)
            {
                if (this.tcs == null)
                {
                    this.tcs = new ETTaskCompletionSource(); // built future.
                }

                var runner = new MoveNextRunner <TStateMachine>();
                moveNext            = runner.Run;
                runner.StateMachine = stateMachine; // set after create delegate.
            }

            awaiter.OnCompleted(moveNext);
        }
コード例 #15
0
 private ETTask InnerLoadAllAssetsAsync()
 {
     this.tcs     = new ETTaskCompletionSource();
     this.request = assetBundle.LoadAllAssetsAsync();
     return(this.tcs.Task);
 }
コード例 #16
0
 public ETTask <AssetBundle> LoadAsync(string path)
 {
     this.tcs     = new ETTaskCompletionSource <AssetBundle>();
     this.request = AssetBundle.LoadFromFileAsync(path);
     return(this.tcs.Task);
 }