您的位置:首页 > 其它

wpf 多个窗口的显示与隐藏

2015-08-19 22:41 471 查看
[code]  //新建一个lamda的用来开启前台Ui线程,显示gif动画,并置顶
            this.Dispatcher.Invoke(new Action(() =>
            {
                GlobalHelper._mainWindow.grid_prograssbar.Visibility = Visibility.Visible;
                System.Windows.Controls.Panel.SetZIndex(GlobalHelper._mainWindow.grid_prograssbar, 10000 * 1000);
            }));
            //检测gif动画线程是否开启,如果之前存在,关闭,并释放资源
            if (this._threadGif != null)
            {
                this._threadGif.Abort();
                this._threadGif = null;
            }
            //新建一个lambda表达示:用来不停的检测切换函数是否执行完毕,如果执行完毕就关闭gif动画,并线程的资源和把标志量还原为false
            this._threadGif = new Thread(() =>
            {
                while (true)
                {
                    if (this._bIsOverofPanelAnaly == true)
                    {
                        this.Dispatcher.Invoke(new Action(() =>
                        {
                            GlobalHelper._mainWindow.grid_prograssbar.Visibility = Visibility.Hidden;
                        }));
                        this._bIsOverofPanelAnaly = false;
                        this._threadPanelAnaly.Abort();
                        this._threadPanelAnaly = null;
                        this._threadGif.Abort();
                        this._threadGif = null;
                    }
                }
            });

            //开启gif显示线程
            this._threadGif.Start();
            //开启切换方法函数的线程
            if (this._threadPanelAnaly != null)
            {
                this._threadPanelAnaly.Abort();
                this._threadPanelAnaly = null;
            }
            this._threadPanelAnaly = new Thread(BigPanelAnaly);
            this._threadPanelAnaly.Start();
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: