[RESOLVED] Process in Taskmanager
hello
I have a codded a small application with on thread other than main.when close the application through programatically it still shows in task manager.The code
is
mythread.abort()
close()
these are the events of a button click.Please guide me
RAO
Re: Process in Taskmanager
Are you handling the ThreadAbortException that gets thrown? If not then there's no point aborting the thread. If you aren't going to do any cleanup then simply set the IsBackground property of the Thread to True before you Start it and it won't stop the process ending.
Re: Process in Taskmanager
i put it in try catch.sometimes the process closes in taskmanager and sometimes it is visible in taskmanager using 40 to 50% of cpu.my thread runs a loop before it is suspended or aborted.My intention is when we click the close button the thread should stop or abort and my application should terminate with out showing in taskmanager.
RAO
Re: Process in Taskmanager
Are you performing any clean up? If not then aborting a foreground thread is pointless. Make it a background thread and the problem disappears. There's no need to abort because the thread will simply be terminated automatically.
That said, you really should ask yourself whether you SHOULD be performing some clean up. Maybe it's not required, but maybe it is.
Re: Process in Taskmanager
Thank You Friend
As you said I made it background.The Problem solved
RAO
Re: Process in Taskmanager
If your problem has been solved, then select Thread Tools -> Mark Thread Resolved :)
On another note however, termination of threads can cause a lot of problems, especially when these threads are holding DB or server connections, or executing un-managed code. May we see the actual code being run in your alternate thread?
Re: [RESOLVED] Process in Taskmanager
Hi Maxi
I still at the stage of learning.Actually the app which I talked about is my first app using a thread.I think the other thread is only main thread:D