Sporadic problem with ShowDialog - Application Hangs

D

DaveP

I am having a problem in a .NET 2.0 / Visual Studio 2003 application. Most
of the time, the app works fine. But occasionally, I get to the point where
I execute this code:

frmPolStatus.Refresh()
frmPolStatus.ShowDialog()
...

The application hangs up on the ShowDialog method for this Windows form.
When I look at the stack, I get the following information:

system.windows.forms.dll!System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods+IMsoComponentManager.FPushMessageLoop(int dwComponentID = 1, int reason = 4, int pvLoopData = 0) + 0x49d bytes

system.windows.forms.dll!ThreadContext.RunMessageLoopInner(int reason = 4,
System.Windows.Forms.ApplicationContext context =
{System.Windows.Forms.Application.ModalApplicationContext}) + 0x1f3 bytes

system.windows.forms.dll!ThreadContext.RunMessageLoop(int reason = 4,
System.Windows.Forms.ApplicationContext context =
{System.Windows.Forms.Application.ModalApplicationContext}) + 0x50 bytes

system.windows.forms.dll!System.Windows.Forms.Application.RunDialog(System.Windows.Forms.Form form = {chubb.csi.express.common.frmPolStatus}) + 0x34 bytes

system.windows.forms.dll!System.Windows.Forms.Form.ShowDialog(System.Windows.Forms.IWin32Window owner = <undefined value>) + 0x6ab bytes

system.windows.forms.dll!System.Windows.Forms.Form.ShowDialog() + 0xe bytes

Like I said, this code works fine most of the time. I just can't explain
why it's happening sometimes. Any suggestions would be appreciated.

Thanks!
Dave P.
 
T

Tom Shelton

I am having a problem in a .NET 2.0 / Visual Studio 2003 application. Most

2003? That's 1.1 not 2.0 :)
of the time, the app works fine. But occasionally, I get to the point where
I execute this code:

frmPolStatus.Refresh()
frmPolStatus.ShowDialog()
...

The application hangs up on the ShowDialog method for this Windows form.
When I look at the stack, I get the following information:

system.windows.forms.dll!System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods+IMsoComponentManager.FPushMessageLoop(int dwComponentID = 1, int reason = 4, int pvLoopData = 0) + 0x49d bytes

system.windows.forms.dll!ThreadContext.RunMessageLoopInner(int reason = 4,
System.Windows.Forms.ApplicationContext context =
{System.Windows.Forms.Application.ModalApplicationContext}) + 0x1f3 bytes

system.windows.forms.dll!ThreadContext.RunMessageLoop(int reason = 4,
System.Windows.Forms.ApplicationContext context =
{System.Windows.Forms.Application.ModalApplicationContext}) + 0x50 bytes

system.windows.forms.dll!System.Windows.Forms.Application.RunDialog(System.Windows.Forms.Form form = {chubb.csi.express.common.frmPolStatus}) + 0x34 bytes

system.windows.forms.dll!System.Windows.Forms.Form.ShowDialog(System.Windows.Forms.IWin32Window owner = <undefined value>) + 0x6ab bytes

system.windows.forms.dll!System.Windows.Forms.Form.ShowDialog() + 0xe bytes

Like I said, this code works fine most of the time. I just can't explain
why it's happening sometimes. Any suggestions would be appreciated.

Thanks!
Dave P.

Well... Most likely, it's something the form is doing in it's
startup. Can you post some of the forms code?
 
C

cfps.Christian

Not sure I understand why you would be refreshing the form prior to
showing it. Its possible you're dealing with a threading issue with
the refresh working on a separate thread and not finishing before
ShowDialog(). If you must refresh the form before showing it, try a
System.Threading.Thread.Join() between the two and see what that does.
 
D

DaveP

Thanks for your help so far. Here is the code for the form that I'm trying
to display with the ShowDialog. It's very basic:

Option Explicit On
Public Class frmPolStatus
Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

Public Sub New()
MyBase.New()

'This call is required by the Windows Form Designer.
InitializeComponent()

'Add any initialization after the InitializeComponent() call

End Sub

'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub

'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer

'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents dfStatus As System.Windows.Forms.Label
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()
Me.dfStatus = New System.Windows.Forms.Label
Me.SuspendLayout()
'
'dfStatus
'
Me.dfStatus.BackColor = System.Drawing.Color.Silver
Me.dfStatus.Font = New System.Drawing.Font("Arial", 10.2!,
System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0,
Byte))
Me.dfStatus.Location = New System.Drawing.Point(24, 16)
Me.dfStatus.Name = "dfStatus"
Me.dfStatus.Size = New System.Drawing.Size(352, 40)
Me.dfStatus.TabIndex = 0
Me.dfStatus.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
'
'dbStatus
'
Me.AutoScale = False
Me.AutoScaleBaseSize = New System.Drawing.Size(6, 15)
Me.AutoScroll = True
Me.ClientSize = New System.Drawing.Size(400, 80)
Me.Controls.Add(Me.dfStatus)
Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog
Me.MaximizeBox = False
Me.MinimizeBox = False
Me.Name = "dbStatus"
Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
Me.Text = "Policy Status"
Me.ResumeLayout(False)

End Sub

#End Region

End Class
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top