multithreading - C# Close program/form with a Thread -


okay have c# form couple of classes. in 1 of these classes i'm running thread check if external program running. when external program isn't running want program close.

i'm bit of novice me obvious answer use form.close(). not sure if possible access function subclass or different thread!

so questions are: (how) possible close form different thread in other class? more important best practice?

you can use control.invokerequired , control.begininvoke() in order call method on ui thread.

for example (this method has inside form class itself):

public void closeform() {     if (this.invokerequired)     {         this.begininvoke(new action(this.close));     }     else     {         this.close();     } } 

this safe call thread.


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -