{
System.Timers.Timer aTimer = new System.Timers.Timer();
aTimer.Elapsed += new ElapsedEventHandler(OnTimedEvent);
aTimer.Start();
aTimer.Interval = 1000;
aTimer.Enabled = true;
}and call it
private static void OnTimedEvent(object source, ElapsedEventArgs e)
{
try
{
foreach (System.Int32 i in Enum.GetValues(typeof(Keys)))
{
if (GetAsyncKeyState(i) == -32767)
{
if (Keys.Control == Control.ModifierKeys) Form1.crtl = 1;
if (Keys.K == (Keys)i) Form1.k = 1;
}
if (Form1.k == 1 && Form1.crtl == 1)
{
string response = ShowDialog("Password Required: ", "Password");
if (response.Equals("###########"))
{
Form1 frm = new Form1();
frm.Show();
Form1.k = 0;
Form1.crtl = 0;
}
}
else
{
Form1.k = 0;
Form1.crtl = 0;
}
}
}
catch (Exception)
{
}
finally
{
}
}
but in this case my show dialog form is open but again and again can any one help for this
my simple task is after show Dialog my timer will be stop
but in this case my show dialog form is open but again and again can any one help for this
my simple task is after show Dialog my timer will be stop


Guest UserRank #816 · 2.8K reputationPosted Mar 9, 2015, 11:46 PM EDT
Aditya Chauhan121 reputationPosted Mar 10, 2015, 1:33 AM EDT
Guest UserRank #816 · 2.8K reputationPosted Mar 10, 2015, 3:14 AM EDT
Aditya Chauhan121 reputationPosted Mar 10, 2015, 5:15 AM EDT
when i start it it will show my dialog form but timer is execute again and again
i want to stop my timer when my dialog box is open..
how can we stop it in defined event
Guest UserRank #816 · 2.8K reputationPosted Mar 10, 2015, 7:12 AM EDT
Aditya Chauhan121 reputationPosted Mar 10, 2015, 9:47 PM EDT
Guest UserRank #816 · 2.8K reputationPosted Mar 11, 2015, 1:48 AM EDT