• TheCPUWizard (unregistered)

    That construct allows for a breakpoint to be set for the condition where the item exists and then goes away (well at least the member field reference to it is cleared). With just a simple while detecting this condition becomes (Virtually) impossible to distinguish is the field was nothing at the point where the while was encountered.... Given cross-thread considerations and the manipulation of WinForms [and other UI's that are eventually based on Windows Handles] - this type of construct is not at all surprising.

  • (nodebb)

    FirstNameTextBox or txtFirstName seems redundant; what domains would first name be anything but a text field?

    That's more about consistency with other fields where the type of UI element is less obvious. There may also be lblFirstName (the label next to the field, for i18n or conditional coloring or whatever), or some user-defined control wrapped around a generic text box.

  • Keith (unregistered)

    An F prefix is commonly used in Delphi code to show that a variable is a member of a class. I've worked on a C# program that was converted from Delphi and it was full of stuff like this.

  • Sauron (unregistered)

    Or maybe a developer was saying "F my life"?

    Yes, exactly that.

  • Zatapatique (unregistered)

    Or maybe it's the frist frmWait?

  • (nodebb) in reply to Keith

    Which is fitting, because beyond the wrong believe that C# is coming from Java, the .net framework is a successor of Delphi. Heck, the lead designer of Delphi WAS the the designer of .net which was intended as a follow up to Microsoft various C++ class frameworks. Hence BTW the name. They just later aligned it more with Java because they also planned for J#. And this legacy BTW is the biggest weakspot in a lot of language design decision they regret to this day especially when it comes to arrays.

  • Poke Alex (unregistered)

    This uses the lesser-known Hhungarian notation convention.

  • Duston (unregistered)

    Or maybe the "F" is for "Former" so you can have Former Form Myform.

  • Bart (unregistered) in reply to Keith

    Well, IIRC, the actually the F prefix is meant for Fields of a class (the field that getters and setters map to).

  • Duke of New York (unregistered)

    If we can have double-checked locks, why not double-checked busy waits?

  • (nodebb)

    I agree that this is probably a debug trap. I'm sure we are all guilty of occasionally forgetting to remove a trap that's no longer needed.

  • Jeremy (unregistered) in reply to Zatapatique

    Or maybe it's the frist frmWait?

    I think the fourth or fifth is more likely

  • (nodebb)

    Or maybe it's a capital F to indicate that it's a property ???

  • (nodebb)

    I wonder if their IDE or compiler, or perhaps their own code standards, disallowed empty while loops (and possible other blocks like an empty if case)? I can see a case where a "senior" programmer would reject this code in a review if the while block was empty, but accepts this version as submitted, and doesn't know about any better ways to wait for things to happen.

  • DeeKay (unregistered) in reply to Keith


    Delphi lesson: Private member variables that were specifically associated with the "storage" part of setters and getters for properties, since in Delphi you can create a property called "Clientname" (this is not directly a variable as such), have a setter named eg. "SetClientname()", a getter named "GetClientname()" and a private member variable named "FClientname". This avoided the clash with the property name if the "F" were omitted, and makes the intention of the "F" named variable very clear in the class where the developer would have access to the private variable..

  • Mark (unregistered) in reply to prueg

    It seems more like code to fool an automated code scanner that rejects empty loops. This kind of thing would be expected in a place where they decide to replace (not augment) manual code review with an automated tool.

  • Tinkle (unregistered)

    Pick your options:

    a) The compiler optimised the while loop to only check FfrmWait once, then cache the value. b) The compiler generates a warning if a loop is empty. c) There used to be more code in the loop, but it has been optimised, as it was using up too much CPU time :-) d) The developer was full of WTF.

  • Jonathan (unregistered)

    I once used a "busy loop" for a C# app where entries needed to be posted into an accounting system to be ordered by time and insertion order, even if generated at the same moment and we were using UUIDs for DB keys instead of something like a long. We actually encountered this issue in testing were the order was indeterminate. The solution I came up with for the problem was something along the lines of:

    public static void WaitAtLeastOneTick()
        var startTime = DateTime.Now;
        while (DateTime.Now == startTime)
            // Do nothing
  • (nodebb)

    As awful as that smells conceptually, it's almost certainly the cheapest way to accomplish that goal.

    Which points up the truism that for every bit of widely-accepted programming dogma, there exists a situation where that dogma is wrong.

  • Craig (unregistered)
    Comment held for moderation.
  • LZ79LRU (unregistered) in reply to emurphy

    Off the top of my head the controls I might use for a first name are:

    • TextBox = User typed text input.
    • Label = Non editable text display.
    • ComboBox = User selectable drop down.
    • ListBox = List of names displayed for the user.
    • DataGridView = A grid view for displaying DB output. ...

    And those can be combined. For example you might have a control called lblFirstName that is a label whose text says "First Name" which is placed next to another control called tbFirstName which is a TextBox where the user is actually expected to enter said first name. And they can be sitting inside a pFirstName which is a panel located inside a wider structure.

    That is why the Hungarian style notation on Windows Forms Controls and UI elements in general actually makes sense. It allows you to have multiple fields that are semantically linked to the same thing have a sane name after that same thing whilst remaining distinct.

Leave a comment on “While Nothing”

Log In or post as a guest

Replying to comment #:

« Return to Article