Click here to Skip to main content
15,914,820 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a winform application developed in vb.net 2.0 which calls webservices through HTTP request and displays the HTTP response xml by parsing it.Now while logging in based on a parameter in response xml I have to call a webservice at a timely interval.I am achieving it by threading.During logging in if the parameter comes in response xml an background thread is created which keeps calling the webservice at particular interval.The problem is when the user clicks on logout then i need to destroy that thread.I am not being able to figure out how to destroy that thread as calling Abort method would lead to exception.Please help.
Posted

1 solution

The standard way of doing this is to have a flag variable that you periodically check to see if the thread should stop processing. In the case where your process might be sleeping or busy processing, I find it helpful to have a method to signal the thread that it should stop processing.

Saying that, I tend to prefer using something like the Task Parallel Library to handle threading. With TPL, I would just use a CancellationToken.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900