Using timers and threads

adam_k

New member
Joined
Feb 17, 2006
Messages
1
Programming Experience
1-3
Hello everyone

I'm fairly new to VB.NET (Java is my specialty) but my senior project at college is requiring me to play with VB.NET. (Not that I have anything against it, just not my strongest language ;) )

I have an application that has to complete a potentially very time consuming task. I would like to be able to limit the max amount of time that task can process before a timeout exception is thrown. Right now I'm trying to use a Timer to throw the exception but I'm guessing I need to work some threading in here somehow.

I start the timer and execute the task. If the Timer event fires, it throws an exception. Unfortunately it doesn't appear to be catching the exception and halting the task like it should :(

Any ideas or suggestions would be greatly appreciated.
 
I've never actually tried to do it myself but I have read that the proper way to terminate a thread from outside is to call Abort and have the thread itself handle the ThreadAbortException to perfrom any cleanup required. Is that what you're trying to do?
 
Back
Top