Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8359685
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T11:13:43+00:00 2026-06-09T11:13:43+00:00

I know this might be a bit of a ‘silly’ question, but sometimes, I

  • 0

I know this might be a bit of a ‘silly’ question, but sometimes, I just want to loop until a condition is false but I don’t like keeping the loop empty. So instead of:

Visible = true;
while(IsRunning)
{
}
Visible = false;

I usually prefer:

while(IsRunning)
{
    Visible = true;
}
Visible = false;

However, I’m a bit concerned about what exactly happens at the line Visible = true;. Does the Runtime keep executing that statement even though it’s redundant? Is it even advisable to do it this way? Many ‘code-enhancements’ plugins don’t like empty while loops, and I don’t really understand why.

SO:

  • Is there anything wrong with having an empty while loop?

  • Does having a loop such as shown above have any performance effects?

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T11:13:44+00:00Added an answer on June 9, 2026 at 11:13 am

    This is called busy or spin waiting.

    The main problem is, that you are blocking the thread, that is running this while loop. If this thread is GUI thread, then it will result in freezing and unresponsible GUI. And yes, this results in loss of performance, because neither compiler, nor OS can know if they can somehow optimize this while loop.

    Just try making single loop like this and see how one core of your CPU is running at 100%.

    The right way to do this is to use asynchronous programming, where your code gets notified, either by event or language construct (like await) when the previous operation finished running.

    But it is usually used in low-level systems or languages. .NET 4.0 introduces SpinWait construct, that serves as efficient threading sychnronization.

    And in relation to your question. I believe neither should be used. They are both problematic for both debugging, performance and clarity of code.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This might be a bit of an esoteric question, but I just want to
This might sound a bit of an odd question but I know what I
I know this question might sound a little bit crazy, but I tough that
I know this might be a bit of a silly question, probably doing it
This might seem a bit silly, but I want to try and solve this
This might sound like a bit of a silly question but I been looking
I know this might be a bit awkward but I am trying to modify
I know this might be a stupid question, but here it goes. I always
I know this might seem a controversial question but it really is not meant
I know that this question might have been asked like 100 times, but, believe

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.