コード例 #1
0
        protected IEnumerator Start()
        {
            ProgressTask <float, string> task = new ProgressTask <float, string>(new System.Func <IProgressPromise <float, string>, IEnumerator>(DoTask), true);

            /* Start the task */
            task.OnPreExecute(() =>
            {
                Debug.Log("The task has started.");
            }).OnPostExecute((result) =>
            {
                Debug.LogFormat("The task has completed. result:{0}", result);/* only execute successfully */
            }).OnProgressUpdate((progress) =>
            {
                Debug.LogFormat("The current progress:{0}%", (int)(progress * 100));
            }).OnError((e) =>
            {
                Debug.LogFormat("An error occurred:{0}", e);
            }).OnFinish(() =>
            {
                Debug.Log("The task has been finished.");/* completed or error or canceled*/
            }).Start();

            //		/* Cancel the task in three seconds.*/
            //		this.StartCoroutine (DoCancel (task));

            /* wait for the task finished. */
            yield return(task.WaitForDone());

            Debug.LogFormat("IsDone:{0} IsCanceled:{1} Exception:{2}", task.IsDone, task.IsCancelled, task.Exception);
        }
コード例 #2
0
    //public InteractionRequest<CardBagViewModel> WheelRequest
    //{
    //    get { return this.wheelRequest; }
    //}


    public void Download()
    {
        ProgressTask <float> task = new ProgressTask <float>(new Action <IProgressPromise <float> >(DoDownLoad));

        task.OnPreExecute(() => {
            this.command.Enabled    = false;
            this.progressBar.Enable = true;
        }).OnProgressUpdate(progress => {
            this.progressBar.Progress = progress;
        }).OnFinish(() => {
            this.command.Enabled    = true;
            this.progressBar.Enable = false;
            this.command.Execute(null);
        }).Start();
    }
コード例 #3
0
        /// <summary>
        /// 异步加载GameScene场景,带进度条
        /// </summary>
        private void LoadGameScene()
        {
            ProgressTask <float> task = new ProgressTask <float>(new Func <IProgressPromise <float>, IEnumerator>(DoLoadGameScene));

            task.OnPreExecute(() =>
            {
                this.progressBar.Enable = true;//让进度条显示出来
            }).OnProgressUpdate(progress =>
            {
                this.ProgressBar.Progress = progress;//实时更新进度
            }).OnFinish(() =>
            {
                this.progressBar.Enable = false;//隐藏进度条
            }).Start();
        }
コード例 #4
0
        /// <summary>
        /// Simulate a unzip task.
        /// </summary>
        public IProgressTask <float> Unzip()
        {
            ProgressTask <float> task = new ProgressTask <float> (new Action <IProgressPromise <float> > (DoUnzip));

            task.OnPreExecute(() => {
                this.progressBar.Enable = true;
                this.ProgressBar.Tip    = R.startup_progressbar_tip_unziping;
            }).OnProgressUpdate(progress => {
                this.ProgressBar.Progress = progress;                /* update progress */
            }).OnPostExecute(() => {
                this.ProgressBar.Tip = "";
            }).OnFinish(() => {
                this.progressBar.Enable = false;
            });
            return(task);
        }
コード例 #5
0
        /// <summary>
        /// Simulate a loading task.
        /// </summary>
        /// <returns>The scene.</returns>
        public IProgressTask <float> LoadScene()
        {
            ProgressTask <float> task = new ProgressTask <float> (new Func <IProgressPromise <float>, IEnumerator> (DoLoadScene));

            task.OnPreExecute(() => {
                this.progressBar.Enable = true;
                this.ProgressBar.Tip    = R.startup_progressbar_tip_loading;
            }).OnProgressUpdate(progress => {
                this.ProgressBar.Progress = progress;                /* update progress */
            }).OnPostExecute(() => {
                this.ProgressBar.Tip = "";
            }).OnFinish(() => {
                this.progressBar.Enable = false;
            });
            return(task);
        }
コード例 #6
0
        /// <summary>
        /// Simulate a loading task.
        /// </summary>
        public void LoadScene()
        {
            ProgressTask <float> task = new ProgressTask <float>(new Func <IProgressPromise <float>, IEnumerator>(DoLoadScene));

            task.OnPreExecute(() =>
            {
                this.progressBar.Enable = true;
                this.ProgressBar.Tip    = R.startup_progressbar_tip_loading;
            }).OnProgressUpdate(progress =>
            {
                this.ProgressBar.Progress = progress;/* update progress */
            }).OnPostExecute(() =>
            {
                this.ProgressBar.Tip = "";
            }).OnFinish(() =>
            {
                this.progressBar.Enable = false;
                this.dismissRequest.Raise();/* Dismiss StartupWindow */
            }).Start();
        }