App remains in processes

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
 
K

Ken

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
 
J

John

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
 
J

John

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

Thanks

Regards
 
C

Cor Ligthert[MVP]

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
 
C

Ciaran O''Donnell

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.
 
K

kimiraikkonen

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
 
S

SurturZ

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top