Very odd behavior in a Pretty Simple VB .NET forms app

Devon Nullman 60 Reputation points
2025-09-29T16:04:21.7433333+00:00

I am using a Standard form with:

Start Button - Starts the Process

Checkbox that enables/disables the display of found items

Checkbox that enables/disables the display of skipped items

Save Found Items - Button that allows saving the list of found items as a text file

Save Skipped Items - Button that allows saving the list of skipped items as a text file

TextBox "TxtFound" - displays list of found Files

TextBox "TxtSkipped" - displays list of skipped Files

TextBox "TxtProgress" - shows progress and final recap

The form is set to allow making it wider but not taller

The Start Button clears these TextBoxes:

    TxtProgress

    TxtFound

    TxtSkipped
```It also clears the SourceFiles (List Of String) and Skipped (String Builder)

it then brings up a Folder Browser, if a choice is made and OK is clicked, 

a Background Worker Starts and basically runs **John Wein's Get Safe Files**, it reports progress every 100 files.

When the Worker finishes, the text boxes are populated (if the checkbox is checked) and the final stats are displayed.

Here's what is a bit odd:

While it's running, I can move the window anywhere and change the width at will

Once it stops, if I try to widen the window, everything freezes, the mouse pointer becomes the horizontal two sided arrow and nothing responds for about 30 seconds, if I try resizing again, it re-freezes. If I click on Start, and cancel the Folder browser, everything is fine.
Developer technologies | Windows Forms
{count} votes

Answer accepted by question author
  1. Danny Nguyen (WICLOUD CORPORATION) 3,500 Reputation points Microsoft External Staff
    2025-09-30T07:30:58.0333333+00:00

    Hi @Devon Nullman ,

    Thanks for the details.

    I think this is an issue with handling too many lines in TextBoxes. Basically, a multiline TextBox in WinForms does not handle huge strings very well. Each time the form is resized horizontally, the control has to reflow and redraw every line of text, which can easily cause the UI thread to hang for several seconds. That is why the freeze only happens after the textboxes are filled.

    You could test this with resizing when the TextBox is not populated or filled with fewer lines.

    I've found some common ways for dealing with this:

    1. Use a ListBox: ListBox Class (System.Windows.Forms) | Microsoft LearnListBox Class (System.Windows.Forms) | Microsoft Learn
         ListBoxFound.Items.Clear()
         For Each file In FoundFiles
          ListBoxFound.Items.Add(file)
         Next
      
    2. Instead of displaying all lines, only show the most recent N entries (e.g., 500). Keep the full list in memory for saving to file.

    I hope my solution is helpful. Feel free to reach out if there's any problem.

    2 people found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.