加载与隐藏显示

Task.Run(() =>
            {
                try
                {
                    this.LoadingShow();

                    #region 非UI业务

                    #endregion

                    #region UI业务
                    Application.Current.Dispatcher.Invoke(new Action(() =>
                    {
                        //UI控件变化
                    }));
                    #endregion

                    #region 同步任务
                    var task = new Task(() =>
                    {

                        //do something
                    });
                    task.Start();
                    task.Wait();//同步
                    #endregion

                    this.LoadingHide();
                }
                catch (Exception ex)
                {
                    this.BoxErrorMsg(ex.Message);
                    this.LoadingHide();
                }
            });

  

原文地址:https://www.cnblogs.com/jasonlai2016/p/13502131.html