title: Preventing Multiple Async Operations
body: <p>i am working on some code where a <strong>timer tick every seconds</strong> and and get data from Webservice and Shows in on WInform , </p>
  
  <p>What is the best approach to <strong>not</strong> run Multiple operations at same time ?</p>
  
  <p>operation should run if previous operation completed and not running.</p>
  
  <p>the code is</p>
  
  <pre><code>  public void loadbalance()
      {
         try { //Get Data from Internet }
         catch { }
      }
  
      delegate void loadbalancedelegate();
  
      public void loadBalanceAsync()
      {
          loadbalancedelegate worker = new loadbalancedelegate(loadbalance);
          AsyncCallback LoadbalnceCallBack = new AsyncCallback(loadbalanceCompleted);
  
          AsyncOperation async = AsyncOperationManager.CreateOperation(null);
          worker.BeginInvoke(LoadbalnceCallBack,async);
      }
  
      public void loadbalanceCompleted(IAsyncResult result)
      {
           loadbalancedelegate worker = (loadbalancedelegate)          ((AsyncResult)result).AsyncDelegate;
          AsyncOperation async = (AsyncOperation)result.AsyncState;
  
          worker.EndInvoke(result);
      }
  
      delegate void setControlsBalanceDelegate(BalanceOB ball);
  
      void setControlsBalance(BalanceOB ball)
      {
          if (this.InvokeRequired)
              this.Invoke(new setControlsBalanceDelegate(this.setControlsBalance), new
              object[] { ball });
          else
          {    //Update Data on Form (Windows App)
  
          }
      }
  </code></pre>