using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading;
using System.Windows.Forms;
namespace WindowsFormsApplication2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
TestDelegate td = new TestDelegate();
td.cb = SafeSetText;
Thread th = new Thread(new ThreadStart(td.Test));
th.Start();
}
public void SafeSetText(string text)
{
if (this.InvokeRequired)
{
_SafeSetTextCall call = delegate(string s)
{
this.label1.Text = s;
};
this.Invoke(call, text);
}
else
this.label1.Text = text;
}
public delegate void _SafeSetTextCall(string text);
}
}