|
-
July 16th, 2012, 04:53 PM
#1
[RESOLVED] C# .net BackgroundWorker.CancellationPending and while loop
Is the below bad practice?
Code:
while (!_backgroundWorker.CancellationPending)
{
// do a bunch of stuff
// done doing a bunch of stuff
break;
}
I can understand if the while loop said
Code:
while (false variable)
{
// do a bunch of stuff
// done doing a bunch of stuff
falseVariable = true;
}
If the background worker is not cancelled, you can't set _backgroundWorker.CancellationPending in order to get out of the while loop. So you have to break the while in order to get out. I could call _backgroundWorker.CancelAsync() but I don't want to cancel the background worker, I just want it to do all the stuff in this method unless the user hits the Cancel button which calls _backgroundWorker.CancelAsync().
I honestly don't see much of a difference. It just got under my skin when this new employee, whom is not a developer, tells me that it's bad practice to use the break statement, especially when she has never even seen the code i'm using.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|