예제 #1
0
        public override async void Execute()
        {
            _si.SyncStarted();
            _service = new AsyncSyncService(_si);
            try
            {
                await Task.Run(() => _service.ExecuteSync());

                _si.SyncFinished();
            }
            catch (AggregateException e)
            {
                if (e.InnerException.GetType() == typeof(OperationCanceledException))
                {
                    _si.SyncCancelled();
                }
                else if (e.InnerException.GetType() == typeof(DirectoryNotFoundException))
                {
                }
            }
            catch (OperationCanceledException) {
                _si.SyncCancelled();
            }
            catch (DirectoryNotFoundException dnfe)
            {
                _si.SyncCancelled();
                MessageBox.Show(dnfe.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            _service.TaskEnded(_service.MainTaskId);
        }
예제 #2
0
 public override async void Execute()
 {
     _si.SyncStarted();
     _service = new AsyncSyncService(_si);
     try
     {
         await Task.Run(() => _service.ExecuteSync());
         _si.SyncFinished();
     }
     catch (AggregateException e)
     {
         if (e.InnerException.GetType() == typeof(OperationCanceledException))
         {
             _si.SyncCancelled();
         }
         else if (e.InnerException.GetType() == typeof(DirectoryNotFoundException))
         {}
     }
     catch (OperationCanceledException) {
         _si.SyncCancelled();
     }
     catch(DirectoryNotFoundException dnfe)
     {
         _si.SyncCancelled();
         MessageBox.Show(dnfe.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     _service.TaskEnded(_service.MainTaskId);
 }