public void SendMessage() { ChatService.SendMessage(Username, TextToSend) .ContinueWith(task => { if (task.Exception == null) { ClearTextbox_Request.Invoke(); } else { ConnexionFailed_Event.Invoke(); } }); }
public void Login() { var scheduler = TaskScheduler.FromCurrentSynchronizationContext(); ChatService.Connect().ContinueWith(task => { if (task.Exception == null) { new ChatWindow(Username, ChatService).Show(); CloseWindowRequest_Event.Invoke(); } else { ConnexionFailed_Event.Invoke(); } }, scheduler); }