Click here to Skip to main content
15,885,365 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
form1 f2 = new form1 ();
MethodInvoker method = new MethodInvoker(delegate()
{
f2.Name = "xyz";
f2.Text = "xyz";
2.Tag = "xyz";
f2.Show();
});
if (f2.InvokeRequired)//if true then we are not on the control thread
{
f2.Invoke(method);//use invoke to handle execution of this delegate in main thread
}
else
{
method();//execute the operation directly because we are on the control thread.
}

how to create object of form
pls help me
Posted
Updated 18-Jul-11 23:15pm
v2
Comments
[no name] 19-Jul-11 8:16am    
What are you trying to accomplish?

1 solution

form1 f2 = new form1();

is creating your form instance. Unless you're in a thread, the MethodInvolker is not needed, not at all. Either way, you need to tell us what you're trying to do. Is f2.method() what you want ? You realise that if a form1 already exists, this is a new instance, with new values ?
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900