I have a winforms application that includes an Administration form (call it 'adminForm') and another form (call it 'userForm') that is on a timer that opens and runs it on a set time interval.
How do I prevent the userForm from opening when the adminForm is open?
Until recently the userFrom was prevented from opening by using the 'MainWindowTitle' value in code like this:
// Retrieving all running processes for checking admin interface running or not
Process[] objArrPrs = Process.GetProcesses();
foreach (Process objProces in objArrPrs)
{
string strMainWindowTitle = string.Empty;
strMainWindowTitle = objProces.MainWindowTitle.ToString();
if (strMainWindowTitle != string.Empty || strMainWindowTitle != "")
{
// Retrievig process name
string strProcess = objProces.ProcessName;
if ((strMainWindowTitle == "XXXXX" && strProcess == "XXXXX")
|| ((strMainWindowTitle == "XXXXX" && strProcess == "XXXXX.vshost")))
{
blnAdminScrOpen = true;
break;
}
}
}
Where "XXXXX" is the adminForm.Text value (e.g., 'this.Text="XXXXX"). This method was working fine.
However, both forms have now been redesigned and there are no form title bars so now the forms' Text values are null and the code shown above no longer works.
Does anyone have a suggestion on a new c# strategy I can use to prevent the userFrom from opening when the adminForm is open? It's appreciated if you can point me in the direction of some sample code.
Cheers,
Frederickenter code here