|
-
July 16th, 2012, 04:42 PM
#1
[RESOLVED] using break statement in a while loop
So basically I am using a background worker to do a bunch of stuff.
I have a method that says something along the lines of:
Code:
while (!_backgroundWorker.CancellationPending)
{
// do a bunch of stuff here
// end of doing a bunch of stuff
break;
}
My question is this, is there a *BETTER* way to break from this statement when its done doing what it needs to do?
I was told break statements are usually not a good idea to use in while loops. Which kind of got under my skin because the person who told me is fresh from college and has 0 software development experience in a workforce. I can understand that when not using a background worker, you just set some condition to true or false at the end of the while statement which imo is close to the same thing as a break statement.
I don't really see any alternative when using the background worker however. If the background worker has not been cancelled, how else do you get out it?
Thanks,
Joel
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
|