C#中worker线程与UI主线程通信
来源:互联网 发布:软件测试 前景 编辑:程序博客网 时间:2024/05/29 14:40
1. delegate(委托)
这个就类似C++中的函数指针的概念
2. Invoke
在worker线程中使用System.Windows.Forms.Control 的Invoke方法, 就可以与UI主线程进行通信
3. C#中向线程传递数据只有两种方法(<<Professional Csharp 2008的19.3.1给线程传送数据>>:
1) ParameterizedThreadStart
2)定制类
这个就类似C++中的函数指针的概念
2. Invoke
在worker线程中使用System.Windows.Forms.Control 的Invoke方法, 就可以与UI主线程进行通信
3. C#中向线程传递数据只有两种方法(<<Professional Csharp 2008的19.3.1给线程传送数据>>:
1) ParameterizedThreadStart
2)定制类
using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;using System.Net;using System.IO;using System.Threading;namespace Test{ public partial class main : Form { public main() { InitializeComponent(); fun = Function; } private void button1_Click(object sender, EventArgs e) { Thread t1 = new Thread(MyThread); t1.Start(this); } private delegate void FunctionDelegate(string message); private void Function(string message) { this.textBox1.Text = message; } private FunctionDelegate fun; private void MyThread(object o) { main UI = (main)o; UI.Invoke(UI.fun,new Object[] {"KKKKKKKKKKKKK"}); } }}
- C#中worker线程与UI主线程通信
- c#中后台线程更新主线程ui的方法
- c#子线程与主线程之间的通信
- android中UI主线程与子线程深入分析
- Android中UI主线程与子线程
- UI线程与worker线程
- Android,UI主线程与子线程
- Android,UI主线程与子线程
- Android,UI主线程与子线程
- Android,UI主线程与子线程
- Android,UI主线程与子线程
- Android,UI主线程与子线程
- Android,UI主线程与子线程
- Android UI主线程与子线程
- 主线程与UI线程简介
- 工作线程与主线程的通信
- symbian 主线程与子线程通信
- Android子线程与主线程通信
- 灌电流和拉电流
- AppWidgetProvider 应用
- 什么是jQuery
- 在ASP.NET中使用SWFUpload上传控件(中文注释)(详细)
- 最短路之令人蛋碎的代码实践之路
- C#中worker线程与UI主线程通信
- ORACLE 字符串聚合函数 strCat
- xen,xenserver,xcp的区别
- java反射机制访问对象的私有方法
- 网络最大流 — Edmond Karp算法
- Extjs GridPanel用XmlReader读取xml文件的数据
- C++中cin、cin.get()、cin.getline()、getline()、gets()等函数的用法
- 使用UI Automation实现自动化测试--4.7 (TogglePattern)
- dhtmlxgrid 控件使用