c# - Exit Application from ApplicationContext -
I have a custom application contact and I'm trying to eliminate it if I meet specific conditions I'm using a mute to make sure the example.
I have tried base.OnMainFormClosed (empty, empty);
Application.exit ()
and ExitThread
. Everything stops processing, but the process is still going on.
Full main () method:
static zero main () {bool firstInstance; (Mutex Mutex = New Muteux (true, @ "Global \ MyAppNegment", using the first instance) (if (first instance) {MessageBox.Show ("Another example is already running"); Return;} Application. Enabledview style (); Application.SetCompatibleTextRenderingDefault (wrong); Applications (new custom contact);}}
What is the right technology?
Run applications (new custom contact);
It's fine but you're up There is no way to call the ExitThread method, so do not like it:
class program {Private static Custom syntax text app CONTACT; [STAThread] Public static zero main () {// Init code // ... appContext = newCustomContext (); Application.Run (appContext);} Skip Public Static Zero () {appContext.ExitThread ();}}
Now you only prevent message loop Programs for Call to Quit ()
Check your answer better to apply a single instance of the app. The WindowsFormsApplicationBase class also provides shutdownstyle property, which is probably useful to you instead of applicationcontext.
Comments
Post a Comment