c# - Running windows form using backgroundworker -


i've issue runing windows forms under background worker.

private void workerdecrypter_dowork(object sender, doworkeventargs e) {     route =(string) e.argument;     try     {         application.run(new mono(route));     }     catch (exception era) { } } 

mono windows form class, creates new window in decrypt text, when finish process, automatically close window. if there not try catch, exception

an exception of type 'system.reflection.targetinvocationexception' occurred in mscorlib.dll not handled in user code  additional information: exception has been thrown target of invocation. 

you should call application.run on main thread, not in thread. cause tia.

as side note: if not main form, there no need open form in way. can do:

mono m = new mono(route); m.show(); 

if not form, should instance of applicationcontext, don't think seeing code.


Comments

Popular posts from this blog

c++ - OpenCV Error: Assertion failed <scn == 3 ::scn == 4> in unknown function, -

php - render data via PDO::FETCH_FUNC vs loop -

The canvas has been tainted by cross-origin data in chrome only -