Click here to Skip to main content
15,892,072 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hi,

i have an application which has three modules Conversion,testing and editing of a file. Application works fine for one or two flow like

1st flow: Conversion>>testing>>editing
2nd flow : testing>>editing

But after that flow, the application get hanged in "Testing" module. It does not throw any error. I debug the code and find that it hangs at the call of frm.Show().

Please help.


Thanks and Regards,
Jaya Joshi

Code Is:

C#
private void trDashBoard_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            try
            {
                TreeView tree = (TreeView)sender;
                TreeViewItem trvItem = ((TreeViewItem)tree.SelectedItem);
                if (trvItem == null)
                    return;
                if (trvItem.Tag.ToString() == "ADMINISTRATOR" || trvItem.Tag.ToString() == "PROOF READER" || trvItem.Tag.ToString() == "CONVERTOR" || trvItem.Tag.ToString() == "EDITOR")
                    return;
                else
                {
                    TreeViewItem trparent = ((TreeViewItem)trvItem.Parent);
                    if (trparent.Tag.ToString() == "PROOF READER")
                    {
                        Testing frm = new Testing(trvItem.Tag.ToString(),true);
                        frm.Owner = this.Owner;
                        frm.WindowStartupLocation = System.Windows.WindowStartupLocation.Manual;
                   
                        frm.Top =this.Top ;
                       frm.Left = this.Left;
                       System.Threading.Thread.Sleep(500);
                        frm.Show();
                        this.Close();
                    }
                    else if (trparent.Tag.ToString() == "EDITOR")
                    {
                        Editor frmEdit = new Editor(trvItem.Tag.ToString(),true);
                        frmEdit.Owner = this.Owner;
                        frmEdit.WindowStartupLocation = System.Windows.WindowStartupLocation.Manual;
                        frmEdit.Top = this.Top;
                        frmEdit.Left = this.Left;
                        frmEdit.Show();                        
                       this.Close();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Application Error. /n"+ ex.Message+ "/n" + ex.Source  + "/n" +ex.StackTrace);
            }
        }
Posted
Updated 6-Dec-11 1:26am
v3
Comments
Balakrishnan Dhinakaran 6-Dec-11 4:19am    
pls display the code so that it will be easy to identify the error
[no name] 6-Dec-11 4:49am    
EDIT: added code block
Addy Tas 6-Dec-11 9:28am    
Hi,

Does the Testing form have a event that fires when / before it is shown? e.g. resize? If so; does it hang in that event?
jaya_11 12-Dec-11 1:18am    
No event is fired. it hangs at frm.show() method

Hi

I think your problem is your code not work properly see here..

Quote:
System.Threading.Thread.Sleep(500);
frm.Show();
this.Close();
}
else if (trparent.Tag.ToString() == "EDITOR")
{
Editor frmEdit = new Editor(trvItem.Tag.ToString(),true);
frmEdit.Owner = this.Owner;
frmEdit.WindowStartupLocation = System.Windows.WindowStartupLocation.Manual;
frmEdit.Top = this.Top;
frmEdit.Left = this.Left;
frmEdit.Show();
this.Close();


hi in that where use System.Threading.Thread.Sleep(500);
it not execute upper code..so try to call one stop function Like..

C#
Public Void Stop()
{
 System.Threading.Thread.Sleep(500);
}


and call this instead of Thread.Sleep().

IT works...
 
Share this answer
 
v3
Comments
jaya_11 12-Dec-11 1:18am    
Still facing same problem. It doesn't solve my problem.
Hi,

I've been giving the same a try (on forms rather than wpf but most is the same) and did find one small issue here;

first you set

Quote:
Editor frmEdit = new Editor(trvItem.Tag.ToString(),true);
frmEdit.Owner = this.Owner;


then a couple of lines later:

Quote:
this.Close();


If you close the owner of the form you kind of ruin its day...
If you don't wat to see the owner anymore I suggest that you hide it.

Let me know if I got it right, if not i'll spend a bit more time on it

Cheers,

AT
 
Share this answer
 
Comments
jaya_11 20-Dec-11 23:24pm    
no its still not working.
jaya_11 20-Dec-11 23:26pm    
My application is in WPF. and i have webbrowser control in both testing and editor window.
Hi,

My problem get resolved using singleton pattern.

Instead of closing the forms/Window, hide the form. The windows are closed only when application is closing.

Thanks and Regards,
Jaya Joshi
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900