I tried following code to run timer in class library but timer_Elapsed wasn’t fired. I also tried using timer from System.Windows.Forms but it didn’t worked.
private static void SetTimer(DateTime dateTime)
{
timer = new System.Timers.Timer();
TimeSpan timeSpan = dateTime - DateTime.Now;
timer.Interval = timeSpan.Milliseconds;
timer.Elapsed += new System.Timers.ElapsedEventHandler(timer_Elapsed);
timer.Enabled = true;
timer.Start();
}
private static void timer_Elapsed(object myobject, System.Timers.ElapsedEventArgs e)
{
timer.Enabled = false;
timer.Stop();
Start(_appCastURL, _remindLaterAt, _remindLaterFormat);
}
Removed Static from the timer declaration and remove static from event and SetTimer method, put it in the class extending Form in the class library and it worked.