I have two functions as following :
public void SendMessage()
{
}
AND
public void CheckReceivedMessage()
{
}
Now, I want
CheckReceivedMessage(), this function should run continuously and
SendMessage(), this function will run once a week which time will be set by user.
I want to use Threading for this.
For example, the user has set time Wednesday, 4:00 pm then every wednesday at 4:00 pm,
SendMessage() will be executed and if today is friday & the user changes time & day from Wednesday to Sunday, then Upcoming sunday it should be executed...
And I have tried this for it....
private void Form1_Load(object sender, EventArgs e)
{
ThreadStart thrdLoop = new ThreadStart(ThreadLoop);
Thread thrd1 = new Thread(thrdLoop);
thrd1.Start();
}
public void ThreadLoop()
{
while (true)
{
SendMessage();
System.Threading.Thread.Sleep(TimeSpan.FromDays(7));
}
}
But In above, when user will change time, thought
SendMessage() will execute after 7 days after last execution...
Please guide me for this...
Thank you...