How do I eliminate Windows Form doppelganger?

Jay Scarano 1 Reputation point
2022-03-14T03:36:46.007+00:00

I have a single vb.net 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.

Thanks

VB
VB
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
    2022-03-14T10:18:19.737+00:00

    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"
    ProgressMinimum.Update()
    Dim tNum As Int64 = 1000
    ProgressMaximum.Text = tNum.ToString("#,#")
    ProgressMaximum.Update()
    End Sub

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

  2. Jay Scarano 1 Reputation point
    2022-03-14T10:41:25.447+00:00

    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.

    ![182843-image.png]1