Hi.

I have a window that open a new window. I want the new window to close automaticaly after a few seconds.

I tried to use a timer in the new window:

I get InvalidOperationException exeption.

in the constructor I added:

Code Snippet

Timer timer = new Timer(2000);

timer.Elapsed += new ElapsedEventHandler(timer_Elapsed);

timer.Start();

and I also added:

Code Snippet

void timer_Elapsed(object sender, ElapsedEventArgs e)

{

this.Close();

}




Re: Windows Forms General Closing window automaticaly after a few seconds

TilakGopi

Hi,

U might have used timer in System.Threading namespace.Since there is no Elapse event in System.Windows.Forms.Timer class.

I tried using System.Windows.Forms.Timer.It's working fine.

[code lanugage="csharp"]

System.Windows.Forms.Timer timer = new System.Windows.Forms.Timer(this.components);

timer.Interval = 2000;

timer.Tick += new EventHandler(timer_Tick);

timer.Start();

//and the timer_Tick event is

void timer_Tick(object sender, EventArgs e)

{

this.Close();

}

[/code]

Thanx,

Ch.T.Gopi Kumar.