Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Stop Function after 10 seconds

Status
Not open for further replies.

EZEason

Programmer
Dec 11, 2000
213
0
0
US
I have a vb.net console app that reads data from rss feeds. I need a way to stop a function after 10 seconds. The main() calls about 30 functions and if one gets hung up while trying to read a feed, it will error out and stop the whole process. So what I want to do is call the function, and if it takes more then 10 second for a return, end that step and move on to the next functions. Any tips on how to do this?

What doesn't kill you makes you stronger.
 
I think you can add a Timer control. Then add a boolean var to the class that is = to false. Inside of your working loop, add an if statement that checkes to see if the boolean is True and if it is then set it back to false and exit the working loop, else keep working. Once the timer reaches 10 seconds, set the boolean to true to tell the working loop to exit.

Senior Software Developer
 
Just create 30 threads and run them asynchronously and each will finish or crash independently.

-David
2006 & 2007 Microsoft Most Valuable Professional (MVP)
2006 Dell Certified System Professional (CSP)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top