using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Threading;using System.Threading.Tasks;using System.Windows.Forms;namespace Invoketest{ public partial class Form1 : Form { public Form1() { InitializeComponent(); } public void UpdateForm(string param1, string parm2) { this.textBox1.Text = param1 + parm2; } public delegate void UpdateForm_dl(string str1, string str2); private void Calldelegate() { /*在Windows窗体应用程序中使用this.Invoke 在WPF应用程序中使用this.Dispatcher.Invoke*/ this.BeginInvoke(new UpdateForm_dl(UpdateForm), new [] { "我是文本框", "haha" }); //this.Dispatcher.BeginInvoke(new UpdateForm_dl(UpdateForm), new [] { "我是文本框", "haha" }); } public void DoWork() { Calldelegate(); } private void Form1_Load( sender, EventArgs e) { } private void button1_Click( sender, EventArgs e) { Thread thread = new Thread(new ThreadStart(DoWork)); thread.Start(); } }}
遗失的拂晓
继续阅读与本文标签相同的文章
上一篇 :
C#中用WMI实现对驱动的查询
下一篇 :
uses-permission权限列表
-
jdk安装错误1316,jdk-10.0.1
2026-05-26栏目: 教程
-
windows安装mongodb
2026-05-26栏目: 教程
-
Method has too many Body parameters openfeign
2026-05-26栏目: 教程
-
Eclipse中Cannot nest src folder解决方法
2026-05-26栏目: 教程
-
restTemplate重定向问题 &cookie问题
2026-05-26栏目: 教程
