Timers

Purpose of Timer Client

This example illustrates a client that creates a timer. This requires an event loop because timer expiration is an asynchronous event.

Code

using System;
using Spo.SPDlib;
using System.Windows.Forms;
namespace ExamplesOfAPIUsage
{
    class MyAlertPrgram
    {
        // create a SPD class instance
        static SPD m_spd = new SPD();
        [STAThread]
        static void Main(string[] args)
        {
            //string caller = "Main()";
            // Initialize the API.
            // Application name = "timer example"
            // No application qualifier.
            m_spd.SPDInitClient("timer example", null);
            // Client processing...
            // Create the timer.
            // The interval is 10 seconds.
            // No passback data is specified.
            m_spd.SPDAddTimeOut(10000, new SPD.SPD_timerCallback(timerEventCB), 
               null);
            // More processing of client events...
            // Client enters event processing
            Application.Run();
        } // function: Main
        static void timerEventCB(long var, object passback)
        {
            // Client processing...
            // The timer is gone.  It must be recreated if we want it
            //    to go off again in the future.
            m_spd.SPDAddTimeOut(10000, new SPD.SPD_timerCallback(timerEventCB), 
               null);
        } // function: timerAlarmEventCB
    } // class: MyProgram
}// namespace: ClientSampleProgram