上一页 1 ··· 7 8 9 10 11 12 13 14 15 ··· 30 下一页
摘要: 1. Windows程序消息机制 Windows GUI程序是基于消息机制的,有个主线程维护着消息泵。这个消息泵让windows程序生生不息。 Windows程序有个消息队列,窗体上的所有消息是这个队列里面消息的最主要来源。这里的While循环使用了GetMessage() 这个方法,这是个阻塞方法,也就是队列为空时方法就会阻塞,从而这个While循环停止运动,这避免了一个程序把cpu无缘无故的耗尽,让其他程序难以得到响应。当然在某些需要cpu最大限度运动的程序里面就可以使用另外的方法,例如某些3d游戏或者及时战略游戏中,一般会使用PeekMessage()这个方法,它不会被windows阻. 阅读全文
posted @ 2013-05-31 07:36 云中雀 阅读(9166) 评论(1) 推荐(2) 编辑
摘要: Control中Invoke与BeginInvoke是相对于支线线程(因为一般在支线线程中调用,用来更新主线程UI)Invoke立即插入主线程中执行,而BeginInvoke要等主线程执行结束才执行Control.Invoke 方法 (Delegate) : 在拥有此控件的基础窗口句柄的线程上执行指定的委托Control.BeginInvoke 方法 (Delegate) : 在创建控件的基础句柄所在的线程上异步执行指定的委托(一) Control的Invoke和BeginInvoke我们要基于以下认识:(1)Control的Invoke和BeginInvoke与Delegate的Invoke 阅读全文
posted @ 2013-05-30 07:06 云中雀 阅读(4188) 评论(2) 推荐(2) 编辑
摘要: 参考地址:http://topic.csdn.net/u/20100225/13/34310e66-4de2-4293-ac89-a8cee1accf7a.html参考代码: 1 private void Form1_Load(object sender, EventArgs e) 2 { 3 this.dataGridView1.Columns.Add("a", "a"); 4 this.dataGridView1.Columns.Add("b", "b"); 5 this.dataGridView1.C... 阅读全文
posted @ 2013-05-15 23:05 云中雀 阅读(2340) 评论(0) 推荐(0) 编辑
摘要: http://www.cnblogs.com/peterzb/archive/2009/05/29/1491891.html 阅读全文
posted @ 2013-05-15 19:12 云中雀 阅读(150) 评论(0) 推荐(0) 编辑
摘要: http://www.cnblogs.com/wuhuacong/archive/2011/06/30/2095080.html 阅读全文
posted @ 2013-05-15 19:11 云中雀 阅读(151) 评论(0) 推荐(0) 编辑
摘要: 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 云中雀 阅读(1761) 评论(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 云中雀 阅读(519) 评论(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 云中雀 阅读(1889) 评论(0) 推荐(0) 编辑
摘要: 方式一:单进程的实现View Code 1 static class Program 2 { 3 /// <summary> 4 /// 应用程序的主入口点。 5 /// </summary> 6 [STAThread] 7 static void Main() 8 { 9 Application.EnableVisualStyles();10 Application.SetCompatibleTextRenderingDefault(... 阅读全文
posted @ 2013-05-09 10:24 云中雀 阅读(830) 评论(1) 推荐(0) 编辑
上一页 1 ··· 7 8 9 10 11 12 13 14 15 ··· 30 下一页