Timers

This sample consist in a command line demonstrating the use of the TIMER (Timer) class to generate a periodic callback to a method. The sample creates a TIMER object and passes to it a delegate object. When the TIMER fires, the delegate is invoked, and a static method is called asynchronously by a worker thread in the thread pool.

Compiling

To compile the example:

  1. Launch EiffelStudio.
  2. Click Add project
  3. Browse to $ISE_EIFFEL\examplesdotnet\threading\timers\
  4. Choose timers.ecf
  5. Choose the location where the project will be compiled, by default the same directory containing the configuration file.
  6. Click Open.

Running

After you launch the sample, the following output appears: Checking for status updates every two seconds <Hit Enter to terminate the sample> Checking Status. Checking Status. Checking Status. Checking Status. Checking Status. ...

When the display is finished, the application wait for you to pressed the return key to finished the application.

Under the Hood

This application shows how to use the thread TIMER. The timer is launched: create my_timer.make_with_callback (create {TIMER_CALLBACK}.make (Current, $check_status), Void, 0, 2000)and calls the feature check_status that displays the message "Checking Status." every two seconds.

This sample uses the following .NET types:

  • TIMER
  • TIMER_CALLBACK

Notes

This sample is translated from the example located in the Samples\Technologies\Threading\Timers subdirectory of the .NET Framework SDK samples directory of Microsoft Visual Studio .NET.

cached: 04/26/2024 10:16:31.000 AM