Prev | Current Page 500 | Next

Guy Fouch?©, Trey Nash

"Accelerated VB 2008"

Therefore,
you create a TimerCallback delegate that points back to the Shared TimerProc method.
The second parameter to the Timer constructor is an arbitrary state object that you can pass
in. When your timer callback gets called, this state object is passed to the timer callback. In
the example, you have no need for a state object, so you simply pass Nothing. The last two
parameters to the constructor define when the callback gets called. The second-to-last
parameter indicates when the timer should fire for the first time. In the example, you pass 0,
which indicates that it should fire immediately. The last parameter is the period at which the
callback should be called: two seconds. If you don??™t want the timer to be called periodically,
pass Timeout.Infinite as the last parameter. Finally, to shut down the timer, simply call its
Dispose method.
Any code that executes as a result of your TimerCallback delegate must be thread-safe. In
the example, the first thread in the thread pool to call TimerProc() sleeps longer than the next
time-out, so the thread pool calls the TimerProc method two seconds later on another thread,
as you can see in the generated output.
Summary
In this chapter, we covered the intricacies of managed threads in .


Pages:
488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512
katalog stron London Escort Agencies Okulary dieta light pensjonaty w beskidach