SqlBulkCopy.WriteToServer abort, OperationAbortedException?

c# sqlbulkcopy

Question

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?

Accepted Answer

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




Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Is this KB legal? Yes, learn why
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Is this KB legal? Yes, learn why