Run a windows service monthly and quarterly

Last Reply 19 hours ago By rani

Posted 4 days ago

I refered the code on https://www.aspsnippets.com/Articles/Simple-Windows-Service-that-runs-periodically-and-once-a-day-at-specific-time-using-C-and-VBNet.aspx

 

But I am facing problem when I schedule my service monthly and quarterly as it is throwing error at 

 //Get the difference in Minutes between the Scheduled and Current Time.
    int dueTime = Convert.ToInt32(timeSpan.TotalMilliseconds);
 
Because  TotalMilliseconds exceeds the max value of int. So, I used long datatype but then also the scheduler is not set properly. Please suggest me the correct way.
 
Thanks in advance.
You are viewing reply posted by: Indresh 4 days ago.
Posted 4 days ago Modified on 4 days ago

Hi SheetalD,

You need to change your Convert.ToInt32 to below code.

C#

Convert.ToInt64

 

I agree, here is the link: http://e-iceblue.com/free-api