您的位置:首页 > 编程语言 > C#

c#在线程中调用窗口控件2(带参数)

2014-06-01 21:47 232 查看
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Threading;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
string ss = "我是要传入的字符串";
//开启线程(带参数)
ThreadPool.QueueUserWorkItem(new WaitCallback(aa), ss);
}
void aa(object o)
{
//线程中调用控件
textBox1.BeginInvoke(new System.EventHandler(bb), o);
}
void bb(object o, EventArgs e)
{
textBox1.Text = o.ToString();
}
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息