private void CheckForCancel(IProgressCallback progressCallback) { if (progressCallback == null) { return; } if (progressCallback.IsCancelRequested) { progressCallback.AcceptCancel(); throw new OperationCanceledException(); } }