{
this.lblV.Text=data;
}),this.txtV.Text);
});
thread.IsBackground= true;
thread.Start();
}
1,变量 插入 sql 语句
1,跨线程访问组件:
if(this.lblResult1.InvokeRequired)
{
this.lblResult1.Invoke(
new Action<string>(data=>{this.lblResult1.Text=data;}),
i.Tostring()
);
}
2,read control value crossing thread
private void btnRead_Click(object sender,EventArgs e)
{
Thread thread = new Thread(()=>
{
this.txtV.Invoke(new Action<string>(data=>
{
this.lblV.Text=data;
}),this.txtV.Text);
});
thread.IsBackground= true;
thread.Start();
}
3,thread pool
ThreadPool.QueueUserWorkItem((arg)=>
{
xxxxx
});
4,
5,
6, private static object myLock = new object();
lock(mylock)
{
};
7
8
8 delegate
1,declaration delegate
public delegate void PassMsgDelegate(string msg,string childName)
2,write specified method
private void ReceiveMsg(string msg,stirng childName)
{
this.txtContent.Text+=$"from :{childName} :{msg}\r\n";
}
3,create delegate variable
public PassMsgDelegate passMsg;
4,connect delegate variable with method
xxobject.passMsg += ReceiveMsg;
5,use method by delegate variable
passMsg(this.txtSendMsg.Text,this.Text);
//passMsg.Invoke(this.txtSendMsg.Text,this.Text);
1,declaration delegate
public delegate void PassMsgDelegate(string msg,string childName)
2,write specified method
private void ReceiveMsg(string msg,stirng childName)
{
this.txtContent.Text+=$"from :{childName} :{msg}\r\n";
}
3,create delegate variable
public PassMsgDelegate passMsg;
4,connect delegate variable with method
xxobject.passMsg += ReceiveMsg;
5,use method by delegate variable
passMsg(this.txtSendMsg.Text,this.Text);
//passMsg.Invoke(this.txtSendMsg.Text,this.Text);
9,
10,
11 匿名方法
12lambda表达式
13,thread
14,task
15,LINQ