Direct Thread Core Code
private void Button1_Click (object sender, EventArgs e)
{
This.tableLayoutPanel1.Controls.Clear ();
This.tableLayoutPanel1.RowCount = 10;
This.tableLayoutPanel1.ColumnCount = 10;
Button btn;
list<button> lst = new list<button> ();
Thread objThread3 = new Thread (() =
{
for (int i = 0; i <; i++)
{
BTN = new Button ()
{
Name = i.ToString (),
Text = i.ToString (),
size = new Size (50, 50),
};
Lst. ADD (BTN);
}
if (this.tableLayoutPanel1.InvokeRequired)
{
Thread.Sleep (500);
This.tableLayoutPanel1.Invoke (New action<list<button>> (Setcontrols), LST);
}
});
Objthread3.isbackground = true;//is set to a background thread (this is usually set)
Objthread3.start ();
}
private void Setcontrols (list<button> lst)
{
TableLayoutPanel1.Controls.AddRange (LST. ToArray ());
}
Fix the problem of multi-threaded automatic code generation control, resolve parameter mismatch exception