title: How do I Cancel a Silverlight RIA InvokeOperation in a Domain Service?
body: <p>I have the following method on the server:</p>
  
  <pre><code>[Invoke]
  public string GeneratePayroll(string empID,int PeriodID, Guid userID)
  {
  …
  }
  </code></pre>
  
  <p>On the client I call the method as follows:</p>
  
  <pre><code>InvokeOperation&lt;String&gt; payrollGenerationOperation;
  payrollGenerationOperation = _payrollTransContext.GeneratePayroll(EmployeeID, PeriodID, UserID);
  payrollGenerationOperation.Completed += new EventHandler(GeneratePayroll_Completed);
  
  void GeneratePayroll_Completed(object sender, EventArgs e)
  {
  …
  if (!payrollGenerationOperation.IsCanceled)
      txtStatus.Content = "Completed!";
  else
      txtStatus.Content = "Canceled!";
  }
  </code></pre>
  
  <p>On the Cancel Button event:</p>
  
  <pre><code>private void btnCancel_Click(object sender, RoutedEventArgs e)
  {
      payrollGenerationOperation.Cancel();
      btnCancel.IsEnabled = false;
  }
  </code></pre>
  
  <p>But the Cancel is not working, I am not sure about the implementation.</p>