新聞中心
這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
WPF Timer疑難問題解答
WPF Timer在實際使用中出現(xiàn)了一些問題, 經(jīng)過2天努力的調(diào)試才初步發(fā)現(xiàn)了其中的問題。并經(jīng)過各種資料的查找,終于初步解決了這一問題。#t#

我使用 new System.Threading.Timer(TimerCallbacefun, null, 300,0);
- void TimerCallbacefun
(object state) - {
- this.Dispatcher.BeginInvoke
((ThreadStart)delegate - {
- this.container.Children.Clear();
- for (int i=0;i<6;i++)
- {
- mb.Page.Presentation =
m_page.Presentation; - mb.Page = m_page;
- FrameworkElement uiEle =
new Canvas(){ - Top=100*i,
- Height=100,
- width=100
- };
- this.container.Children.
Add(uiEle); - }
- });
- }
這么做是為了延時異步加載, 但是不是每次都能創(chuàng)建所有的Canvas, 不知道WPF Timer到底什么問題。
WPF Timer問題解決方法: 改為同步創(chuàng)建, 或者使用線程異步創(chuàng)建都能成功。
當(dāng)前題目:WPF Timer疑難問題解答
網(wǎng)頁地址:http://www.fisionsoft.com.cn/article/djejsoh.html


咨詢
建站咨詢
