<span id="mktg5"></span>

<i id="mktg5"><meter id="mktg5"></meter></i>

        <label id="mktg5"><meter id="mktg5"></meter></label>
        最新文章專題視頻專題問答1問答10問答100問答1000問答2000關鍵字專題1關鍵字專題50關鍵字專題500關鍵字專題1500TAG最新視頻文章推薦1 推薦3 推薦5 推薦7 推薦9 推薦11 推薦13 推薦15 推薦17 推薦19 推薦21 推薦23 推薦25 推薦27 推薦29 推薦31 推薦33 推薦35 推薦37視頻文章20視頻文章30視頻文章40視頻文章50視頻文章60 視頻文章70視頻文章80視頻文章90視頻文章100視頻文章120視頻文章140 視頻2關鍵字專題關鍵字專題tag2tag3文章專題文章專題2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章專題3
        問答文章1 問答文章501 問答文章1001 問答文章1501 問答文章2001 問答文章2501 問答文章3001 問答文章3501 問答文章4001 問答文章4501 問答文章5001 問答文章5501 問答文章6001 問答文章6501 問答文章7001 問答文章7501 問答文章8001 問答文章8501 問答文章9001 問答文章9501
        當前位置: 首頁 - 科技 - 知識百科 - 正文

        WPF實現定時刷新UI界面功能

        來源:懂視網 責編:小OO 時間:2020-11-27 22:35:35
        文檔

        WPF實現定時刷新UI界面功能

        本文實例為大家分享了WPF定時刷新UI界面展示的具體代碼,供大家參考,具體內容如下:代碼。using NHibernate.Criterion;using System;using System.Collections.Generic;using System.Collections.ObjectModel;using System.ComponentModel;using System.Data;using System.Linq;using System.Text;using System.Threading;using System.Windows;using System.Windows.Controls;using System.Windows.Data;});();}))。
        推薦度:
        導讀本文實例為大家分享了WPF定時刷新UI界面展示的具體代碼,供大家參考,具體內容如下:代碼。using NHibernate.Criterion;using System;using System.Collections.Generic;using System.Collections.ObjectModel;using System.ComponentModel;using System.Data;using System.Linq;using System.Text;using System.Threading;using System.Windows;using System.Windows.Controls;using System.Windows.Data;});();}))。

        本文實例為大家分享了WPF定時刷新UI界面展示的具體代碼,供大家參考,具體內容如下

        代碼:

        using NHibernate.Criterion;
        using System;
        using System.Collections.Generic;
        using System.Collections.ObjectModel;
        using System.ComponentModel;
        using System.Data;
        using System.Linq;
        using System.Text;
        using System.Threading;
        using System.Windows;
        using System.Windows.Controls;
        using System.Windows.Data;
        using System.Windows.Documents;
        using System.Windows.Input;
        using System.Windows.Media;
        using System.Windows.Media.Imaging;
        using System.Windows.Navigation;
        using System.Windows.Shapes;
        using Visifire.Charts;
        
        namespace SunCreate.CombatPlatform.Client
        {
         public partial class MainPage : UserControl
         {
         private System.Timers.Timer timerNotice = null;
        
         public MainPage()
         {
         InitializeComponent();
         }
        
         private void MainPage_Loaded(object sender, RoutedEventArgs e)
         {
         #region 通知公告
         if (timerNotice == null)
         {
         BindNotice();
        
         timerNotice = new System.Timers.Timer();
         timerNotice.Elapsed += new System.Timers.ElapsedEventHandler((o, eea) =>
         {
         BindNotice();
         });
         timerNotice.Interval = 60 * 1000;
         timerNotice.Start();
         }
         #endregion
         }
        
         private void MainPage_SizeChanged(object sender, SizeChangedEventArgs e)
         {
        
         }
        
         #region 綁定通知公告
         private void BindNotice()
         {
         System.Threading.Tasks.Task.Factory.StartNew(() =>
         {
         try
         {
         int total = 0;
         TES_NOTICE info = new TES_NOTICE();
         IList<TES_NOTICE> list = new List<TES_NOTICE>();
        
         list = HI.Get<INoticeService>().GetListPage(null, DateTime.MinValue, DateTime.MinValue, 1, 50, ref total);
        
         Dispatcher.Invoke(new Action(() =>
         {
         noticeListView.ItemsSource = list;
         }));
         }
         catch
         {
        
         }
         });
         }
         #endregion
        
         }
        }
        
        

        說明:在 System.Timers.Timer 的事件中使用 BackgroundWorker 是無效的,即如下代碼不能正常刷新界面:

        using NHibernate.Criterion;
        using System;
        using System.Collections.Generic;
        using System.Collections.ObjectModel;
        using System.ComponentModel;
        using System.Data;
        using System.Linq;
        using System.Text;
        using System.Threading;
        using System.Windows;
        using System.Windows.Controls;
        using System.Windows.Data;
        using System.Windows.Documents;
        using System.Windows.Input;
        using System.Windows.Media;
        using System.Windows.Media.Imaging;
        using System.Windows.Navigation;
        using System.Windows.Shapes;
        using Visifire.Charts;
        
        namespace SunCreate.CombatPlatform.Client
        {
         public partial class MainPage : UserControl
         {
         private System.Timers.Timer timerNotice = null;
        
         public MainPage()
         {
         InitializeComponent();
         }
        
         private void MainPage_Loaded(object sender, RoutedEventArgs e)
         {
         #region 通知公告
         if (timerNotice == null)
         {
         BindNotice();
        
         timerNotice = new System.Timers.Timer();
         timerNotice.Elapsed += new System.Timers.ElapsedEventHandler((o, eea) =>
         {
         BindNotice();
         });
         timerNotice.Interval = 60 * 1000;
         timerNotice.Start();
         }
         #endregion
         }
        
         private void MainPage_SizeChanged(object sender, SizeChangedEventArgs e)
         {
        
         }
        
         #region 綁定通知公告
         private void BindNotice()
         {
         PT_USER_INFO user = new PT_USER_INFO();
         IList<TES_COMBAT_TASK> taskList = new List<TES_COMBAT_TASK>();
        
         BackgroundWorker worker = new BackgroundWorker();
         worker.DoWork += (s, e) =>
         {
         user = HI.Get<Cache.ICacheService>().UserCache.GetCurrentUserInfo();
         taskList = HI.Get<ITaskService>().GetCombatTaskByUserIDUnfinished(user.ID.ToString());
        
         };
         worker.RunWorkerCompleted += (s, e) =>
         {
         try
         {
         taskListView.ItemsSource = taskList;
         }
         catch { }
         };
         worker.RunWorkerAsync();
         }
         #endregion
        
         }
        }
        
        

        也可以使用 DispatcherTimer 刷新界面,但耗時的操作不能放在DispatcherTimer的事件中執行,否則界面會卡,那么耗時的定時操作,比如查詢數據庫,需要再用一個 System.Timers.Timer,相對比較麻煩。

        聲明:本網頁內容旨在傳播知識,若有侵權等問題請及時與本網聯系,我們將在第一時間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com

        文檔

        WPF實現定時刷新UI界面功能

        本文實例為大家分享了WPF定時刷新UI界面展示的具體代碼,供大家參考,具體內容如下:代碼。using NHibernate.Criterion;using System;using System.Collections.Generic;using System.Collections.ObjectModel;using System.ComponentModel;using System.Data;using System.Linq;using System.Text;using System.Threading;using System.Windows;using System.Windows.Controls;using System.Windows.Data;});();}))。
        推薦度:
        標簽: 設置 定時 界面
        • 熱門焦點

        最新推薦

        猜你喜歡

        熱門推薦

        專題
        Top
        主站蜘蛛池模板: 亚洲妓女综合网99| 91亚洲国产成人久久精品网站| 国产免费人成视频尤勿视频| 精品国产麻豆免费网站| 亚洲午夜AV无码专区在线播放| 亚洲一二成人精品区| 毛片免费在线观看| 免费国产精品视频| 色吊丝性永久免费看码| 国产亚洲精久久久久久无码77777| 国产成人无码精品久久久久免费| 亚洲人成人网站色www| 性色午夜视频免费男人的天堂| 亚洲精品美女久久久久| 五月婷婷综合免费| 亚洲精品国产首次亮相| 亚洲精品国产日韩无码AV永久免费网| 一级毛片大全免费播放下载| 国产三级在线观看免费| 欧美亚洲精品一区二区| 在线观看免费高清视频| 日本亚洲中午字幕乱码| 免费可以看黄的视频s色| 中文字幕在线观看亚洲日韩| 午夜亚洲国产成人不卡在线| 亚洲一区电影在线观看| 日韩成人免费aa在线看| 中文字幕不卡高清免费| 亚洲伊人成无码综合网| 在线免费观看亚洲| 亚洲AV无码一区二区三区电影 | 国产高清免费视频| 亚洲人AV在线无码影院观看| 亚洲午夜精品久久久久久浪潮| 久久免费看少妇高潮V片特黄| 亚洲综合色婷婷在线观看| 亚洲裸男gv网站| 毛片免费vip会员在线看| 国产高清对白在线观看免费91| 亚洲国产成人资源在线软件| 亚洲AV日韩精品一区二区三区 |