Is there a way to delay an event handler (say for 1 sec) in Windows Forms

Posted by Essam on Stack Overflow See other posts from Stack Overflow or by Essam
Published on 2009-03-15T22:30:11Z Indexed on 2010/03/18 6:11 UTC
Read the original article Hit count: 408

Filed under:
|
|
|

I need to be able to delay the event handlers for some controls (like a button) to be fired for example after 1 sec of the actual event (click event for example) .. is this possible by the .net framework ?

I use a timer and call my code from the timer's tick event as below but I am not sure if this is the best approach !

void onButtonClick( ..)
{
   timer1.Enabled = true;
}

void onTimerTick( ..)
{
   timer.Enabled = false; 

   CallMyCodeNow();
}

© Stack Overflow or respective owner

Related posts about c#

Related posts about .NET