Modal form will not close

groads2

Newcomer
Joined
May 23, 2012
Messages
16
I have a form that is instantiated with the following code. When I click the ok or cancel buttons that are on the form I call me.close() but the form does not close. I just stays on my screen and my application is hung. The form is not running on the same thread as the main form.

Code:
           If _frmAppManpower Is Nothing Then
                _frmAppManpower = New frmAppManpower
                AddHandler _frmAppManpower.FormClosed, AddressOf OnFormClosed
            End If
            With _frmAppManpower
                .RosterID = rosterID
                .ApparatusName = apparatusName
                .TopMost = True
                .WindowState = FormWindowState.Normal
                .ShowDialog(whndle)
                .TopMost = False
                .Activate()
            End With
 
Last edited by a moderator:
The form is not running on the same thread as the main form.

Does the form work properly if you launch it from the main thread? WinForms is not thread-safe, and all your UI code should be running on the same thread.
 
Back
Top