Hi,
I'm working on a simple web service which exports data from some data store into the database.
The service runs every 20 seconds (testing interval).
Intervals are implemented through System.Timers.Timer
class.
What is happening at the moment is:
- Service starts
- Timer starts
- 20 seconds pass and service starts the export
- Export doesn't finish within next 20 seconds and another thread kicks off attempting to do the same export.
- Eventually service crashes.
I was going to wrap the export into a separate thread, but not sure whether this will fully fix the problem.
Increasing a time interval isn't an option because I'm not sure how big the future exports will be.
Any suggestions are welcome.
Thank you
Edit:
I guess what I'm after is: 1. Start timer 2. Start thread 3. Start export 4. Don't let timer to start another thread until previous one completes...