Quantcast
Channel: Windows Forms General forum
Viewing all articles
Browse latest Browse all 12583

Why would this method freeze?

$
0
0


This method freezes on the line commented to that effect ("<-- hangs here when called from main (frmCentral) passing frmProgress and itself (frmCentral)")

I know this code is kind of strange (or at least, whoever wrote it thinks a lot different than I do/has a radically different approach).

This is a Windows CE.Net project, using .NET 1.0, running in Windows XP mode on Windows 7, running VS 2003.

One class (frmProgress) has both a "progress" form that sits on top of other forms AND a helper class named pbDialogs. This method is part of that helper class, and in the problem case is passed an instance of the "progress form" and an instance of the main form (frmCentral). It is called *from* the main form. So it takes as args the form within its own *.cs file as well as the project's main form.

In frmProgress.cs:

public class frmProgress : Form
. . .


public class pbDialogs : IDisposable
. . .

public void ShowDialog(Form progForm, Control mainForm) // <-- member method of pbDialogs 
{
try
{
Control topControl = mainForm.TopLevelControl;
string caption = topControl.Text;
progForm.Text = caption;
topControl.Text = "--pending--"; // Don't show parent in task list

progForm.Activated += new EventHandler(form_Activated);
progForm.Closed += new EventHandler(form_Closed);
m_top = progForm; // New top-most form
progForm.ShowDialog(); //<-- hangs here when called from main (frmCentral) passing frmProgress and itself (frmCentral)

m_top = (Form) topControl; // The top dialog just changed
progForm.Activated -= new EventHandler(form_Activated);
progForm.Closed -= new EventHandler(form_Closed);

topControl.Text = caption; // Make visible in task list again
Activate((Form) topControl); // And make it the active window
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);//TODO: Remove <-- apparently, it's not an error (nothing being displayed)
SSCS.ExceptionHandler(ex, "frmPrograss.ShowDialog");
}
} // ShowDialog

Here's how it is called, from the main form:

using (pbDialog = new pbDialogs())
{
ProgressBar = new frmProgress(this, true);
ProgressBar.SetProgressLabelText("Site Mapping Data");
typeProgress = (int) ProgressStates.ProgressQRY;
ProgressBar.label1.Text += " (Receiving)";
if (pbDialog != null)
{
pbDialog.ShowDialog(ProgressBar, this); // it hangs within the call to this
}
else
{
ProgressBar.ShowDialog();
}
ProgressBar = null;
evt.Set();
}

Why would pbDialogs hang in its call to ShowDialog()?

Viewing all articles
Browse latest Browse all 12583

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>