public static void SetTopMost(Form form, bool topMost = true)
{
if (form.InvokeRequired)
{
form.Invoke(new setTopMost(SetTopMost), form, topMost);
}
else
{
// need to toggle to false and
// then to true for this to take effect
if (topMost)
{
form.TopMost = false;
form.TopMost = true;
}
else
{
form.TopMost = false;
}
}
}