首页 > 其他 > 详细

后台运行程序时的进度条使用

时间:2014-03-06 04:50:32      阅读:491      评论:0      收藏:0      [点我收藏+]

当后台执行大量程序的时候,前端需要有一个progressBar来显示进度,但是当后台在执行的时候会导致前台页面的卡死,以下在前台实现变动。

 

1. 声明一个委托并实例化

bubuko.com,布布扣
        private delegate void UpdateUiDelegate(DependencyProperty dp, Object value);

        private readonly UpdateUiDelegate _updateTextDelegateDelegate;
        private readonly UpdateUiDelegate _updateProgressDelegate;
bubuko.com,布布扣

 

2.向实例化之后的对象赋值

bubuko.com,布布扣
         _updateTextDelegateDelegate = currentTextBlock.SetValue;
         _updateProgressDelegate = scanProgressBar.SetValue;
bubuko.com,布布扣

 

3.调用委托

bubuko.com,布布扣
         Dispatcher.Invoke(_updateProgressDelegate, System.Windows.Threading.DispatcherPriority.Background, new object[] { RangeBase.ValueProperty, Convert.ToDouble(count) });

         Dispatcher.Invoke(_updateTextDelegateDelegate, System.Windows.Threading.DispatcherPriority.Background, new object[] { TextBlock.TextProperty, info.FullName });
bubuko.com,布布扣

后台运行程序时的进度条使用,布布扣,bubuko.com

后台运行程序时的进度条使用

原文:http://www.cnblogs.com/Alf7/p/3582865.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!