0

I'm currently running two tasks which are copying data to my SQL Server. The data copying is done by the method SqlBulkCopy.WriteToServer. I'm using the SqlRowsCopiedEvent to show the user the amount of rows that are successfully copied. Every time this event is called I'm checking if the cancellation token is requested. If the token is requested (button click) I'm setting SqlRowsCopiedEventArgs.Abort to true. This aborts the SqlBulkCopy.WriteToServer method.

Now I'm getting an OperationAbortedException. I looked at the documentation and it says that this exception is thrown whenever the user is cancelling an operation. However I'm not 100% sure if it's right that this indeed throws when I abort the write to server method?

user247702
  • 23,641
  • 15
  • 110
  • 157
LimpSquid
  • 327
  • 6
  • 17
  • 2
    it isn't amazingly surprising that setting `Abort` to `true` results in an `OperationAbortedException`... – Marc Gravell Sep 10 '14 at 09:34
  • Yes, I indeed thought the same. However I want to be sure it is normal that that exception is thrown. – LimpSquid Sep 10 '14 at 09:36
  • 3
    You say that the documentation states that this exception is thrown in exactly this case. Why do you still wonder something might be wrong? – usr Sep 10 '14 at 10:35

1 Answers1

1

The documentation states that this exception is thrown in this case. This is normal behavior.

usr
  • 168,620
  • 35
  • 240
  • 369