| 00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
| /* ScheduleTimers.cs, see http://ultramessaging.github.io/UMExamples/schedule_timers/dotnet/ */
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using com.latencybusters.lbm;
public class ScheduleTimers {
public static int wait = 1;
static void Main(String[] args) {
LBMContext ctx = null; /* Context object: container for UM "instance". */
/*** Initialization: create necessary UM objects. ***/
try {
ctx = new LBMContext();
}
catch(LBMException ex)
{
System.Console.Error.WriteLine("Error initializing LBM objects: " + ex.Message);
System.Environment.Exit(1);
}
TimerCallback cb = new TimerCallback();
LBMTimer timer = new LBMTimer(ctx,1000,(LBMTimerCallback)cb.onExpiration,null);
while (wait == 1)
{
try {
System.Threading.Thread.Sleep(500);
}
catch (Exception eex)
{
System.Console.Error.WriteLine("Error System.Threading.Thread.Sleep() exception: " + eex.Message);
System.Environment.Exit(1);
}
}
ctx.close();
} /* main */
public void onExpiration(Object cbArg)
{
System.Console.Out.WriteLine("Timer executed. Set wait to 0 so application can cleanly exit");
wait = 0;
}
public class TimerCallback
{
public void onExpiration(Object cbArg)
{
System.Console.Out.WriteLine("Timer executed. Set wait to 0 so application can cleanly exit");
wait = 0;
}
}
} /* class ScheduleTimers */
|