Application.Exit()

  • Thread starter Thread starter KevinD
  • Start date Start date
K

KevinD

When I call Application.Exit(), my application doesn't completely
terminate--the debugger doesn't fully shut down, and although the forms
all get closed, there is something "hanging on" somewhere.

When I look in Settings/System/Memory/Running Programs nothing appears.

Any ideas how I can determine what is still running, and what I have
forgotten to clean up properly?

Thanks.

-Kevin
 
Thanks for the response guys.

It turns out my limited knowledge of the framework has gotten me in a
little trouble. I was using a singleton class for my database access
(cacheing my connection within) and I also used the IDisposable
interface on this class with the following code.

bool is_disposed = false;
protected virtual void Dispose(bool disposing)
{
if (!is_disposed)
{
if (disposing)
{
//dispose all managed resources.
}
// dispose of all unmanaged resources.
connection.Dispose();
}
is_disposed = true;
}

public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}

~dataUtils()
{
Dispose(false);
}

I wasn't calling the Dispose() method explicitly--I was letting
Application.Exit() shut everything down. Unfortunately, when this
happened, the process got hung up on the connection.Dispose() command.
Why this get's stuck here, I don't know--the connection object is not
null when the code gets here.

I can work around the problem by either a) removing the IDisposable
interface, or b) explicitly calling Dispose() on the class. I would
choose a) because I still want to cache my connection.

Do you think this is a problem? Is there really any need for explicit
Dispose code here?

-Kevin
 
Back
Top