ved hjælp af System;
hjælp System.Timers;
namespace evnt1
{
class Class1
{
statisk int count = 0;
statisk streng dispstrg = "Hvordan har du det"
public static void Main ()
{
Timer mt = ny Timer (100);
mt.Elapsed + = ny ElapsedEventHandler (mt_Elapsed)
mt.Start ();
Console.ReadLine ();
metode m = ny metode ();
m.mt1.Elapsed + = ny ElapsedEventHandler (m.show)
m.mt1.Start ();
Console.
ReadLine ();
}
privat static void mt_Elapsed (objekt afsender, ElapsedEventArgs e)
{
Hvis (tæller Konsol .Write (dispstrg [count ++% dispstrg.Length])
}
}
public class metode
{
offentlige Timer MT1 = ny Timer (250);
public void show (objekt afsender, ElapsedEventArgs e)
{
Console.WriteLine ("Kan du finde, at morsomt") ;
mt1.
Stop ();
}
}
}