[Mono-list] System.Timers

Jamil Geor jamil_geor@yahoo.co.nz
Tue, 02 Nov 2004 23:55:48 +1300


Hi,
	I am trying to run the code below, but it doesn't seem to work.  It
should send output to the console after 3 seconds, but It doesn't seem
to trigger off my event.  Is there something wrong with my code, or is
it a problem with System.Timers?

I am using Mono 1.0.1

Here is the code:

using System;
using System.Timers;

public class MyTime 
{
	public static void Main (string [] args)
	{
		Timer myTimer = new Timer (3000);
		myTimer.Elapsed += new ElapsedEventHandler (MyTimeEvent);

		while (Console.Read () != 'q');
	}
	
	private static void MyTimeEvent (object o, ElapsedEventArgs args)
	{
		Console.WriteLine ("Hello");
	}
}

Thanks 
Jamil