I have a winForm c#,and I have a function for sending sms
i want to know how can i call it, run it at specific time
please help me.
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
VulpesPosted Oct 28, 2013, 4:57 PM
DateTime now = DateTime.Now;
DateTime specific = DateTime.Today.AddHours(12); // for 12.00 noon say today
int ms = (int)(specific - now).TotalMilliseconds;
_tmr.Interval = ms;
Hemant SrivastavaPosted Oct 28, 2013, 4:47 PM
In the following way, you can create a timer, set the specific time interval and start the timer in FormLoad() method.
-------------------------------------------------------------------
Timer _tmr = new Timer();
_tmr.Interval = 5000; // interval in millisecond
_tmr.Tick += new EventHandler(tmr_Tick);
_tmr.Start();
--------------------------------------------------------------------
// This is the event handler for the timer
void tmr_Tick(object sender, EventArgs e)
{
// Here, call the SMS Sending method
}
Hope it will help.