Hi all,
I have a problem with a service that sends mailings to customers. Basically, what the mailing does is check a database table for scheduled mailings to send. When it finds one, it gets the addresses from another db table and loops through them to send an email to every address.
This works fine except in the following two situations.
1. After a restart of the service, if there are mailings scheduled, the first mailing to be sent is sent twice. Later mailings are ok.
2. After a reboot of the server and a restart of the service it is the same except that the first mailing gets sent multiple times, up to 19 times!! Later mailings are again ok.
It doesn't seem to be a problem in the code (c#) because it only happens the first time after a restart (or is that short-sighted?). It only happens after a restart when there is already a mailing waiting to be sent. When the service is started with no mailings waiting and I then add a new mailing, everything works fine.
Any ideas? Any help would be greatly appreciated.
Peter
Loading
PeterPosted Nov 24, 2011, 5:52 AM
I just found out what the other problem was. I set my timer to 100 ms and on elapse started to send mailings. The routine that sends the mailing sets a flag to indicate that a mailing is running and no action should be taken until the mailing is finished. However, this flag was not set until more than 8 seconds after the first elapse. So every time the timer elapsed a new run was initiated right until the flag did get set. It only takes so much time for the flag to be set during startup after a reboot.
I simply set the timer to one minute and the problem went away.
Again thanks for your help.
Peter
Sam HobbsPosted Nov 23, 2011, 2:56 PM
Sam HobbsPosted Nov 23, 2011, 2:52 PM
PeterPosted Nov 23, 2011, 12:17 PM
Can you expand on your answer?
Rahul MPosted Nov 23, 2011, 11:50 AM