I use this method to close forms according to their Id, but if I open a form with Id 2, close it once, it works fine, but if I open a form again with Id 2, it doesn't close the form (the form just stays on the screen). I have no idea what is going on and desperately need help. Thanks!
public void OutsideClose(long Id)
{
if (InvokeRequired)
{
Invoke(new Action<long>(OutsideClose), Id);
}
else
{
var FormToClose = ListForms.Find(a=> a.Id == Id);
if(FormToClose != null)
{
FormToClose.Dispose();
OpenForms.Remove(Id);
}
}
}