I have a simple WinForms application that I’m using to monitor a system. The Main form is connected to a SignalR hub, and opens a form when receiving a message:
hubConnection.On("ReceiveMessage", (string aMessage) =>
{
AlertMessageForm sAlertMessageForm = new AlertMessageForm(aMessage);
sAlertMessageForm.TopMost = true;
var sResult = sAlertMessageForm.ShowDialog();
});
This message is supposed to catch the users attention and open in front of the computers all open windows. The problem is, the AlertMessageForm SOMETIMES opens behind the all open windows, but most often it opens in front of all windows.
The Main Form is almost always hidden, using the Hide()
method if that matters, but the problem seems to occurr regardless if the Main Form is hidden or shown.
I’ve tried using TopMost = true
, TopLevel = true
, showing the form as a dialog. But it still opens behind all windows sometimes.
KingBilly is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.