title: How to make windows service request wait until the previous request is complete
body: <p>I am working on a window services application and my window service will call one of the web services in certain intervals (for example 3 min). From the web service I will get data from a database and using that data I will send an email.  </p>
  
  <p>If I am having huge sets of rows in my db table it will take some time to send the mail. Here I have the problem: The window services send the first request and it will handle some set of records. So, while processing it by the web service, the window service sends another request to the web service before it has completed the first request. 
  Due to this, the web service gets the same records from db again and again whenever it receives a new request from the windows service.</p>
  
  <p>Can any one suggest me how to lock the previous request until it completes its work or some other way to handle this situation?</p>
  
  <p><strong>Web Service call:</strong></p>
  
  <pre><code>protected override void OnStart(string[] args) 
  { 
     timer.Elapsed += new ElapsedEventHandler(OnElapsedTime); 
     timer.Interval = 180000; 
     timer.AutoReset = false; 
     timer.Enabled = true; 
  }
  </code></pre>
  
  <p><strong>Inside Method</strong></p>
  
  <pre><code>        using (MailWebService call = new MailWebService())
          {
  
              try
              {
                  call.ServiceUrl = GetWebServiceUrl();
                  System.Net.ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };
  
                  call.CheckMailQueue();
  
  
              }
              catch (Exception ex)
              {
                  LogHelper.LogWriter(ex);
              }
              finally 
              {
  
              }
          }
  </code></pre>