internal static void StartChat(String remoteUri) { SessionWindow sessionWindow = null; MessagingWindow messagingWindow = null; lock (SessionWindow.Windows) { sessionWindow = SessionWindow.Windows.FirstOrDefault(w => w.CanStartChat(remoteUri)); } if (sessionWindow == null) { lock (MessagingWindow.Windows) { messagingWindow = MessagingWindow.Windows.FirstOrDefault(w => w.CanStartChat(remoteUri)); } if (messagingWindow == null) { messagingWindow = new MessagingWindow(remoteUri); } messagingWindow.StartChat(remoteUri); } else { sessionWindow.StartChat(remoteUri); } }