TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Adwait
NA
8
0
Process lingering around after application quit
Aug 15 2007 3:20 PM
When I run my windows application, a main form is loaded. I then fire another thread which keeps scanning for some RFIDs. When the RFID scanning is done I stop the process by simply setting a boolean variable to true. So that later I can resume it when needed.
Soemthing like
while(!StopThread)
{
.... my thread code
}
When someone clicks Alt + F4 on the main window, the form closes down. But I still have a process running in my task manager. This has to do with the thread that I fired because if I disable it, the application shuts down clean.
Here is what I tried and did not work.
1. I set the boolean variable to true so that the thread function stopes. I then tried calling m_workerThread.Abort() and handled a excetion for ThreadAbortException. Then in the finally block I put m_workerThread.Join(). I also tried removing the join.
2. In the dispose of the main form, I tried to do a getprocessbyname and kill that process if its running. That did not work either.
Can someone please tell me why would this be happening and whats the clean way to solve this problem ?
Adwait
Reply
Answers (
5
)
Accesing frmMain events from a thread
How we can use multithreading in C#.