Beispiel #1
0
 public void ListenServerEvents()
 {
     Task.Run(() =>
     {
         try
         {
             while (true)
             {
                 ServerEvents.RaiseEvent(ExpectEvent());
             }
         }
         catch (Exception e) when(
             e is SerializationException ||
             e is EndOfStreamException ||
             e is ObjectDisposedException ||
             e is IOException)
         {
             Utils.MessageBox.ShowException(e);
         }
         finally
         {
             if (!_isClosing)
             {
                 MessageBox.Show("Une erreur est survenue : le serveur n'est plus accessible.", "Erreur - Serveur inaccessible", MessageBoxButton.OK, MessageBoxImage.Error);
                 Disconnect();
                 Application.Current.Dispatcher.Invoke(() =>
                 {
                     ((MainWindow)Application.Current.MainWindow).SetView <MainView>();
                 });
             }
         }
     });
 }