Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Application.Exit

0 views
Skip to first unread message

Steph

unread,
May 30, 2003, 10:26:05 AM5/30/03
to
Hello,

On my WinForm, I put a button to quit Application. I put Application.Exit()
on the event Click.

When I click, WinForm is closed but the application is always running in
task Manager. What can I do ?

Thanks

Steph


Kieran Benton

unread,
May 30, 2003, 10:38:23 AM5/30/03
to
Weird I was just about to ask a question along the same lines as this! Ive
got a multithreaded application that uses a generalized syncronizatio nclass
so i can do Invokes between threads. Its not easy to define the scope of
this and I would like an easy no nonsense way of just ending all threads
started by my application. I take it that Application.Exit() does not do
this.

Thanks in advance
Kieran

"Steph" <st...@nospamplease.com> wrote in message
news:#5lBGcrJ...@TK2MSFTNGP11.phx.gbl...

Greg Ewing [MVP]

unread,
May 30, 2003, 10:49:17 AM5/30/03
to
Steph, what else are you doing in your WinForm? You must still have a
resource in use when you call Application.Exit(). Are you using multiple
threads? Make sure that any external resources/references that you've
opened in your app are also explicitly closed when you call
Application.Exit()

--
Greg Ewing [MVP]
http://www.claritycon.com/


"Steph" <st...@nospamplease.com> wrote in message
news:#5lBGcrJ...@TK2MSFTNGP11.phx.gbl...

Greg Ewing [MVP]

unread,
May 30, 2003, 10:52:18 AM5/30/03
to
Kieran, there are two ways you could go about this:

1. Fire an event which all of your threads are subscribed to which tells
them to quit. When the thread receives the event it does any cleanup it has
to do and then quits.
2. On your thread references in the main thread (the ones you used to start
the threads) call .Abort(). That will raise a ThreadAbortException on the
thread which you should catch and handle appropriately.

--
Greg Ewing [MVP]
http://www.claritycon.com/


"Kieran Benton" <kie...@teejpc.homeip.net> wrote in message
news:OlbHhkrJ...@TK2MSFTNGP11.phx.gbl...

Kieran Benton

unread,
May 30, 2003, 10:59:05 AM5/30/03
to
Thanks Greg.

"Greg Ewing [MVP]" <gewing@_NO_SPAM_claritycon.com> wrote in message
news:ursgSsrJ...@TK2MSFTNGP11.phx.gbl...

Steph

unread,
May 30, 2003, 11:49:44 AM5/30/03
to
Thanks Greg.
I have thread in my Application; I understand now.

thanks

Steph

"Greg Ewing [MVP]" <gewing@_NO_SPAM_claritycon.com> a écrit dans le message
de news: #Tz9mqrJ...@TK2MSFTNGP10.phx.gbl...

MiHA

unread,
May 30, 2003, 12:18:29 PM5/30/03
to

You can tell your other threads that they are background threads so they
automaticly exit when the main thread gets killed.

<thread name>.IsBackground = true;
<thread name>.Start();


Kieran Benton

unread,
May 30, 2003, 12:41:03 PM5/30/03
to
AH right, wondered what the significance of that was. Does setting it to
true have any other side effects like lowering the thread's priority?

Kieran

"MiHA" <marko.m...@kr.hinet.hr> wrote in message
news:ejb3YcsJ...@TK2MSFTNGP12.phx.gbl...

MiHA

unread,
May 30, 2003, 5:27:25 PM5/30/03
to

> AH right, wondered what the significance of that was. Does setting it to
> true have any other side effects like lowering the thread's priority?
>
> Kieran
>

I think not, but I could be wrong


Hates Spam@adelphia.net SleazySt

unread,
May 31, 2003, 1:25:18 PM5/31/03
to
Kieran Benton wrote:
> AH right, wondered what the significance of that was. Does setting it to
> true have any other side effects like lowering the thread's priority?
>
> Kieran


From MSDN:

Background threads are identical to foreground threads except for the fact
that background threads do not prevent a process from terminating. Once all
foreground threads belonging to a process have terminated, the common
language runtime ends the process by invoking Abort on any background
threads that are still alive.


0 new messages