static void AddShell(Shell shell) { if ((shell != null) && !String.IsNullOrWhiteSpace(shell.ShellId)) { try { if (Shells.ContainsKey(shell.ShellId)) { Shell s = (Shell)Shells[shell.ShellId]; if (s.Equals(shell)) { return; } s.Close(); } Shells[shell.ShellId] = shell; } catch (Exception) { } } }