Killing the processes.

  • Thread starter Thread starter Saurabh Sharma
  • Start date Start date
S

Saurabh Sharma

Hi
I have made a Windows Form and in it few calculations and processos are
running. When i close the form the process continues to run until that
particular function in finished. I cant use Environment.Exit 0 as they and
in the subform and i want to load the main form when i close that.
Please tell me how to stop all the functions once a loop is closed

Regards
Saurabh Sharma
 
Saurabh,

When your app closes, you should send a signal to the thread to indicate
that it should stop its work, and close down gracefully (whether through a
variable that is constantly checked, or some other mechanism).

Only then, should your app shut down. Forcefully killing the thread is
a bad idea.

Hope this helps.
 
Saurabh,

if you don't care about gracefully completing the worker thread
operations before quitting your application, you might consider about
setting the IsBackground property of your worker thread to true.
Otherwise, the application keeps running until the secondary thread
completes.

However, it is surely better to quit gracefully and provide cleanup
code, as Nicholas pointed out.

HTH

Claudio Brotto
 
Hi Saurabh
what you need to do is to notify the thread that you application is done
and no need for it to be running ( the way you choose to implement that is
variant and dependes on the logic of your application) . Then the thread
now( when it get such notification) can do its own exit.
Mohamed M .Mahfouz
Developer Support Engineer
ITWorx on behalf of Microsoft EMEA GTSC
 
Hi all
Yeah i am currently doing that returning a bool when the form is closing.
And that form has many funtions in it. So i am checking it in every
function. Just wanted to know is there anything which automatically tells
that form is closed.
Thanx for the suggestions they were of great help

Saurabh
 

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

Back
Top