using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Threading;
using System.IO;
。。。。
private void button1_Click(object sender, EventArgs e)
{
//立即转换
Thread th1 = new Thread(new ThreadStart(threading_test_01));
th1.Start();
}
///////////////////////////////////////////////////////////////////////////////
//多线程测试函数
///////////////////////////////////////////////////////////////////////////////
public void threading_test_01()
{
for (int i = 0; i < 1000; i++)
{
SetTextBoxValue(i.ToString());
}
}
///////////////////////////////////////////////////////////////////////////////
//以下为多线程赋值textbox1的类
///////////////////////////////////////////////////////////////////////////////
private delegate void CallSetTextValue();
//通过委托调用
void SetTextBoxValue(string fi)
{
TextBoxSetValue tbsv = new TextBoxSetValue(this.textBox1, fi);
if (tbsv.TextBox.InvokeRequired)
{
CallSetTextValue call = new CallSetTextValue(tbsv.SetText);
tbsv.TextBox.Invoke(call);
}
else
{
tbsv.SetText();
}
}
class TextBoxSetValue
{
private TextBox _TextBox;
private string _Value;
public TextBoxSetValue(TextBox TxtBox, String Value)
{
_TextBox = TxtBox;
_Value = Value;
}
public void SetText()
{
_TextBox.Text = _Value;
}
public TextBox TextBox {
set { _TextBox = value; }
get { return _TextBox; }
}
}
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Threading;
using System.IO;
。。。。
private void button1_Click(object sender, EventArgs e)
{
//立即转换
Thread th1 = new Thread(new ThreadStart(threading_test_01));
th1.Start();
}
///////////////////////////////////////////////////////////////////////////////
//多线程测试函数
///////////////////////////////////////////////////////////////////////////////
public void threading_test_01()
{
for (int i = 0; i < 1000; i++)
{
SetTextBoxValue(i.ToString());
}
}
///////////////////////////////////////////////////////////////////////////////
//以下为多线程赋值textbox1的类
///////////////////////////////////////////////////////////////////////////////
private delegate void CallSetTextValue();
//通过委托调用
void SetTextBoxValue(string fi)
{
TextBoxSetValue tbsv = new TextBoxSetValue(this.textBox1, fi);
if (tbsv.TextBox.InvokeRequired)
{
CallSetTextValue call = new CallSetTextValue(tbsv.SetText);
tbsv.TextBox.Invoke(call);
}
else
{
tbsv.SetText();
}
}
class TextBoxSetValue
{
private TextBox _TextBox;
private string _Value;
public TextBoxSetValue(TextBox TxtBox, String Value)
{
_TextBox = TxtBox;
_Value = Value;
}
public void SetText()
{
_TextBox.Text = _Value;
}
public TextBox TextBox {
set { _TextBox = value; }
get { return _TextBox; }
}
}
浙公网安备 33010602011771号