c# - How to display a form from another thread -


i running code in seperate thread on c# winforms app (the name of form mainform):

displaydownload form2 = new displaydownload();  form2.topmost = true;   form2.show(); 

but when thread launched, form never opens. if move code onto main thread of app, opens fine, if launch it's own thread, form never opens.

i tried using accepted answer post: calling windows form thread (.net) error:

cannot convert anonymous method type 'system.delegate' because not delegate type

here code trying utilize:

mainform.invoke(delegate {          displaydownload form2 = new displaydownload();            form2.topmost = true;           form2.show(); }); 

can please tell me doing wrong , how work?

add new methodinvoker(delegate(), so:

mainform.invoke(new methodinvoker(delegate()  {              displaydownload form2 = new displaydownload();                form2.topmost = true;               form2.show(); })); 

Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -