winform线程给lable赋值
/// <summary>
/// 线程给lable赋值
/// </summary>
/// <param name="value"></param>
private delegate void SetTextDelegate(string value);
private void WriteLabel(string s)
{
if (label1.InvokeRequired)
{
SetTextDelegate d = new SetTextDelegate(WriteLabel);
label1.Invoke(d, new object[] { s });
}
else
{
label1.ForeColor = Color.Red;
label1.Text = s;
}
}