Hi there.
I am displaying a string which will appear 1 char at a
time. The problem is after it display the 1st string, it
will keep on continue.
When i uncomment the myTimer.stop(), it does not even run
at all.. cannot see anything on the command prompt.
Any help?
using System;
using System.Timers;
namespace Handling_Events ___1_char_at_a_ time
{
/// <summary>
/// Summary description for Class1.
/// </summary>
class Class1
{
static int counter = 0;
static string displayString = "Hello World!";
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
//
// TODO: Add code to start application here
//
Timer myTimer = new Timer(100);
myTimer.Elapsed += new ElapsedEventHan dler(WriteChar) ;
myTimer.Start() ;
//myTimer.Stop();
Console.ReadLin e();
}
static void WriteChar(objec t source, ElapsedEventArg s e)
{
Console.Write(d isplayString[counter++ %
displayString.L ength]);
}
}
}
Any help?
I am starting to learn events as well.
Regards,
Chua Wen Ching
I am displaying a string which will appear 1 char at a
time. The problem is after it display the 1st string, it
will keep on continue.
When i uncomment the myTimer.stop(), it does not even run
at all.. cannot see anything on the command prompt.
Any help?
using System;
using System.Timers;
namespace Handling_Events ___1_char_at_a_ time
{
/// <summary>
/// Summary description for Class1.
/// </summary>
class Class1
{
static int counter = 0;
static string displayString = "Hello World!";
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
//
// TODO: Add code to start application here
//
Timer myTimer = new Timer(100);
myTimer.Elapsed += new ElapsedEventHan dler(WriteChar) ;
myTimer.Start() ;
//myTimer.Stop();
Console.ReadLin e();
}
static void WriteChar(objec t source, ElapsedEventArg s e)
{
Console.Write(d isplayString[counter++ %
displayString.L ength]);
}
}
}
Any help?
I am starting to learn events as well.
Regards,
Chua Wen Ching
Comment