App remains in processes

  • Thread starter Thread starter John
  • Start date Start date
J

John

Hi

I have a winform app. When this app is closed it remains under 'Processes'
in Task Manager. What is the problem and how can I ensure that app closes
completely and releases all resources?

Thanks

Regards
 
I have a winform app. When this app is closed it remains under
'Processes' in Task Manager. What is the problem and how can I ensure
that app closes completely and releases all resources?

I had that problem when I had a thread that monitored a port for incoming
data. I added 'Environment.Exit(0);' to Program.cs to close off any
threads.

Ken
 
Hi

I am closing the app by clicking the cross on the top right corner of the
main window. Where should I use End?

Thanks

Regards
 
Its just a winform app that runs a series of queries on an access backend
database. Can't think of anything special.

Thanks

Regards
 
John,

Never use End, it kills an application and you get unpredictable results,
that the taskmanager does not show direct the end of a program is a
behaviour of Windows OS.

Cor
 
Try attaching a debugger to it with the solution loaded and pausing the
application, on the 'Debug Location' toolbar, look at each of the threads in
turn and see if the code they are executing gives you any clues. It might be
on a blocking call to something.
 
Hi

I have a winform app. When this app is closed it remains under 'Processes'
in Task Manager. What is the problem and how can I ensure that app closes
completely and releases all resources?

Thanks

Regards

Hi,
There may be several reasons, for example, if your application is
alive and uses notify control, you need to close it from notification
icon by assigning a contextmenu control by adding "me.close" to one of
its items. You can also make notfifyicon usable by putting code on
form's load:

NotifyIcon1.Icon = Me.Icon

Also, if your application contains some "hidden" forms which are
previously hidden though you think you've exited, your application is
supposed to be still alive as background process, and you need to
close hidden form with "close" method gently.

Additionaly, your application may remain alive if it interops with
other assemblies or processes during its lifetime depending on your
application's references.

Finally, make sure you're disposing all resources using with "Using"
statement if one of your application's classes use an IDisposable
object.

Hope this helps,

Onur Güzel
 
Right you are, Application.Exit is better than End.

Microsoft continues its grand tradition of obliterating the usefulness of
any keyword that was part of ANSI BASIC, I see >:-{

(Besides DIM, GOTO, FOR-NEXT, and IF-THEN, are there any left??)

To John - put Application.Exit in the Form.FormClosed event of your main
form. You are better off if you clear out all global and module level
variables first. So if you have anything with a .Dispose method, call that
first. Setting all your global and module level variables to Nothing wouldn't
hurt either.

Ideally, you shouldn't need to use Application.Exit. If you dispose of all
your variables correctly, the application should just end when the main form
is closed.

--
David Streeter
Synchrotech Software
Sydney Australia
 
Back
Top