Reputation: 77
I have a windows service which fires a request after every 5 minutes to a Web API controller. The Web API will retrieve some data from application A and process it and then put it into application B. Basically it looks for new and updated records after from A every 5 minutes - I have different record types and the intervals may be different depending on the frequency of change. Each record will have a Modified_Date column. This column will be used to retrieve data from A. I have a table which is used by the windows service to fire requests. This table stores the last modified_date of each record type. So on each request say I retrieve 1000 records I will get the max date of those 1000 records and store in the database on the next request i will then make use of this date.
Now my issue is sometimes depending on network speed and number of records retrieved the five minutes might lapse whilst the first request is still executing. I don't want the second request to start before the first is done.
How best can I check if the first request is completed?
Upvotes: 2
Views: 1629
Reputation: 125
You could make a singleton service to hold a flag that checks whether the previous request has finished. The request sets the flag when it starts end releases the flag when it ends.
Upvotes: 2