April 2008
Intermediate to advanced
704 pages
17h 49m
English
Problem
You need to execute a method in a separate thread periodically.
Solution
Declare a method containing the code you want to execute periodically. The method's signature must match that defined by the System.Threading.TimerCallback delegate; in other words, it must be a subroutine (not a function) and take a single Object argument. Create a System.Threading.Timer object and pass it the method you want to execute, along with a state Object that the timer will pass to your method when the timer fires. The runtime will wait until the timer expires, and then call your method using a thread from the thread pool.
|
Read now
Unlock full access