How do I eliminate Windows Form doppelganger?

Jay Scarano 1 Reputation point

I have a single Form with a few buttons, a progressBar and a textBox that get updated regularly. After clicking the button to start some intensive processing, if I move the window, there's an exact duplicate underneath. The duplicate is locked, but it shows the same progress control operating exactly the same as the original. The main window shows "not responding".

Using .NET 5.0, and visual studio 2019.

I can't seem to find a description of the problem in all my searches.

Can anyone help? I can't believe I'm the first to experience such.


An object-oriented programming language developed by Microsoft that is implemented on the .NET Framework. Previously known as Visual Basic .NET.
2,607 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Jay Scarano 1 Reputation point

    This version doesn't give the duplicate window. As soon as you attempt to move the window, it becomes non-responsive and the controls (ProgressBar and TextBox) stop updating. I will provide a version that does ghost shortly. I believe there's an additional "Update" that causes the duplicate.

    Option Compare Text
    Public Class GenBootlegTxts
    Public foldersProcessedCount As Int64
    Private Sub GenBootlegTxts_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    ProgressBar.Minimum = 0
    ProgressBar.Maximum = 1000
    ProgressBar.Step = 25
    ProgressMinimum.Text = "0"
    Dim tNum As Int64 = 1000
    ProgressMaximum.Text = tNum.ToString("#,#")
    End Sub

    Sub GenTxtsButton_Click(sender As Object, e As EventArgs) Handles GenTxtsButton.Click
    End Sub
    Private Sub NextLevel()
        foldersProcessedCount += 1
        Do While True
            foldersProcessedCount += 1
            If foldersProcessedCount Mod 25 = 0 Then
            End If
    End Sub
    Private Sub UpdateProcessingProgress(count As Int64)
        If count >= ProgressBar.Maximum * 0.85 Then
            ProgressBar.Maximum += ProgressBar.Maximum
            ProgressMaximum.Text = ProgressBar.Maximum.ToString("#,#")
        End If
        ProgressTextBox.Text = "# processed: " & foldersProcessedCount
    End Sub

  2. Jay Scarano 1 Reputation point

    If I add a ProgressBar.Upgrade between 22 and 23 above, it allows me to eventually move the window, but the controls stop updating. If I add a MsgBox that pops up every 150K iterations or so, it's clear that the software is still running, and when the MsgBox pops up, the controls start working again until I try and move it.