Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

Chapter 22. Timers and Time-Driven Progr... > Delaying the Execution of a Function

22.3. Delaying the Execution of a Function

Timers make it easy to delay the execution of a function. Simply set up a timer that fires only once, and set the delay for the time you'd like to wait before firing. A common application for this is creating a timeout, a predetermined time allotted for an action to take place, such as a server response, after which the action is aborted.

In Example 22-5, you'll use a timer to create something you're no doubt familiar with from browsing the internet, a redirect script. First you'll create the Redirect class, which will handle the timer and navigation. Then you'll set up an example class to test it.


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial