3

Please do not close the question straight away. The almost similar problem is also discussed in the following threads.

  1. Windows Forms and ShowDialog problem
  2. Form.ShowDialog() or Form.ShowDialog(this)?

But, these do not solve my problem. The problem never occurred in my development machine. It occurred in the user machine but not always. In fact it occurred only 3 or 4 times.

When it happens it seems the application/calling form is frozen. If I can guess (as I am not seeing it on the screen) where the close button is and click on it on the called form, it closes and application goes back to usable state until it occurs again.

My views are encapsulated within the presenter, so I am not calling ShowDialog() from within the view but through the presenter.

MainPresenter
{
    MainPresenter(IMainView view)
    {
        _view = view;
    }
    …
    …
    OpenSecondView()
    {
        var secondPresenter =_presenterFactory.Create<SecondPresenter>();
        secondPresenter.Ininialize(_view);
    }
}

// Initialize method in the SecondPresenter
Initialize(owner)
{
    _secondView.ShowDialog(owner); 
}

I am using observing presenter style of MVP explained here http://www.aspiringcraftsman.com/2008/11/23/model-view-presenter-styles/

Questions:

  1. How can I reproduce the problem in my development machine and fix it?
  2. If I use Show() and set TopMost = true, is it possible this problem to occur?
  3. What are the things I should consider that may cause this problem?

If Show() absolutely guarantees that the problem will not occur, I will go with Show(). I kind of lost faith in ShowDialog() on this.

Any help will be greatly appreciated.


** The problem does not occur for a specific screen/view. It occurs randomly.

** For all the forms except main form, ShowInTaskBar is set to false.

pushkin
  • 9,575
  • 15
  • 51
  • 95
Shuhel Ahmed
  • 963
  • 8
  • 14

2 Answers2

0

Have you tried adding a this.Activate() in the load event for the form, because I have had a similar problem.

pushkin
  • 9,575
  • 15
  • 51
  • 95
James
  • 2,812
  • 3
  • 22
  • 33
  • Could you explain a little more about why should i need to call this.Active()? – Shuhel Ahmed Sep 25 '11 at 03:10
  • I have seen dialogs popup but behind the current form which means having to alt-tab to get the dialog. Is this the problem that you are refering to? Did you find a solution as it has been some time. – James Nov 11 '11 at 15:54
0

You can try using TopMost = true for the form

pushkin
  • 9,575
  • 15
  • 51
  • 95
aamir
  • 151
  • 6