I wrote a code to call doMethod() every 2 minutes with System.Timers.Timer, the doMethod() use a web service on server A, but if the server A or IIS on the server A stops, after the reboot, doMethod() does not work. my questions are:
- does timer stops after the server rebooting? (I know the answer is no, but I'm confused)
- does the web service can't login or what, after the server rebooting?
here is the code :
public Form1()
{
InitializeComponent();
System.Timers.Timer timer = new System.Timers.Timer
{
Interval = 120000 //2 minutes
};
timer.Elapsed += timer_Elapsed;
timer.Start();
}
private void timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
var session = new WebApiLoginSession("http://172.27.1.1", "webserviceUser", "somePassword");
if (string.IsNullOrEmpty(session.ID))
{
doMethod();
}
}