Comments: ** Comment from web user: noderino **
I can not provide a sample because it is not happening every time i call MessageBox.Show(). But i can give you more detail. I am using a WCF service with async calls. Some methods take about 1 minute. during this time i change foreground window to something else for example notepad. ComputeOwnerWindow method checks whether one of the windows in the application is activated. Actualy it is not because foreground window is set to notepad window and ComputeOwnerWindow returns null. If owner is null message window show in screen center. I think this is a multi monitor problem. When i set the owner in MessageBox.Show it works normally (tested over 3 days).
with IMHO, i wanted to say "in my opinion".
This should work.
```
private static Window ComputeOwnerWindow()
{
Window owner = null;
if( Application.Current != null )
{
owner = Application.Current.MainWindow;
foreach( Window w in Application.Current.Windows )
{
if( w.IsActive )
{
owner = w;
break;
}
}
}
return owner;
}
```