摘要: http://www.cnblogs.com/tracky/archive/2013/03/30/2991083.html 阅读全文
posted @ 2013-05-14 21:09 云中雀 阅读(272) 评论(0) 推荐(0) 编辑
摘要: WinForm 之Control.Invoke 和Control.BeginInvoke 方法的使用Control 不能在创建它的 Thread 之外被调用。但可以通过 invoke 来保证 Control 线程安全。在跨线程更新的时候,Control 会检查 CurrentThread 是否为创建 Control 的线程,并报错!示例代码如下:private void btnStart_Click(object sender, EventArgs e){ //注意:特地不使用 Timer 控件 Thread thread = new Thread(Fun); thre... 阅读全文
posted @ 2013-05-14 19:42 云中雀 阅读(1768) 评论(0) 推荐(0) 编辑
摘要: 在WINForm开发过程中,我们经常遇到填充比较多的数据到界面时,有时候界面卡死啦,这时候我们最好的办法是采用线程来对数据进行收集,然后再体现在界面上。1.第一种是比较繁琐的采用异步进行操作。创建一个委托:private delegate List<string> UpdateUIDelegate(int count);制定委托方法:UpdateUIDelegate ui = GetData; //收集数据的方法 private List<string> GetData(int count) { List<stri... 阅读全文
posted @ 2013-05-14 19:25 云中雀 阅读(524) 评论(0) 推荐(0) 编辑
摘要: 1 using System; 2 using System.Collections.Generic; 3 using System.ComponentModel; 4 using System.Data; 5 using System.Drawing; 6 using System.Linq; 7 using System.Text; 8 using System.Windows.Forms; 9 10 namespace CallBackTest11 {12 public partial class Form1 : Form13 {14 public Fo... 阅读全文
posted @ 2013-05-14 19:15 云中雀 阅读(1894) 评论(0) 推荐(0) 编辑