Update Label1 with button1:
Private Delegate voidUpdateforminvoke (stringAstringb ="B"); Private voidUpdateForm (stringAstringb ="B") {Label1. Text= A +" - "+b; } Private voidButton1_Click (Objectsender, EventArgs e) {Thread th=NewThread (Test); Th. Start (); } voidTest () {Updateforminvoke Uli=NewUpdateforminvoke (UpdateForm); This. BeginInvoke (Uli,New Object[] {"A" }); }
Parameter count mismatch exception:
Modify Code 1:
Private Delegate void Updateforminvoke (stringstring"B"); Private void UpdateForm (stringstring b) { "" + b; }
Modify Code 2:
Private Delegate void Updateforminvoke (stringstring b); Private void UpdateForm (stringstring"B") { " " + B; }
The same error occurred as a result
Modify Code 3:
void Test () { new Updateforminvoke (updateform); This New Object " A " " B " }); }
No optional arguments are omitted, no exception.
C # using an asynchronous delegate to update a form on another thread cannot omit optional arguments