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
Post a Comment