Beispiel #1
0
        private void OnDownloadCompleted(object sender, TaskCompletedEventArgs args)
        {
            HttpFileDownloadTask task = sender as HttpFileDownloadTask;

            if (task.Status != TaskStatus.Succeeded)
            {
                task.Completed -= OnDownloadCompleted;

                if (File.Exists(task.LocalPath))
                {
                    File.Delete(task.LocalPath);
                }

                if (Directory.Exists(Path.GetDirectoryName(task.LocalPath)))
                {
                    Directory.Delete(Path.GetDirectoryName(task.LocalPath));
                }

                tasks.Remove(task.LocalPath);

                Hyena.Log.ErrorFormat("Could not download eMusic track: {0}",
                                      task.Error.ToString());
            }
            else
            {
                import_manager.Enqueue(task.LocalPath);
            }
        }
 private void taskm_Completed(object sender, TaskCompletedEventArgs <byte> e)
 {
     logger.Log(string.Format(Resources.ReadLockCompleted, e.Result), Category.Debug, Priority.None);
     Locks      = e.Result;
     Dlg.Result = true;
     Dlg.Close();
 }
Beispiel #3
0
 private void taskm_Completed(object sender, TaskCompletedEventArgs <IMemory> e)
 {
     logger.Log(string.Format(Resources.ReadCompleted, GetMemoryType()), Category.Debug, Priority.None);
     Memory     = e.Result;
     Dlg.Result = true;
     Dlg.Close();
 }
 protected override void OnCompleted(TaskDelegateMetadata meta, TaskCompletedEventArgs completed)
 {
     if (meta.Completed != null)
     {
         Dispatcher.Invoke(new Action(() => meta.Completed(completed)));
     }
 }
Beispiel #5
0
        private void OnDownloadTaskCompletedHandler(object sender, TaskCompletedEventArgs args)
        {
            HttpFileDownloadTask task = sender as HttpFileDownloadTask;
            FeedEnclosure        enc  = task.UserState as FeedEnclosure;

            if (enc != null)
            {
                if (args.Error != null || task.Status == TaskStatus.Failed)
                {
                    enc.DownloadStatus = FeedDownloadStatus.DownloadFailed;
                }
                else if (!args.Cancelled)
                {
                    if (task.Status == TaskStatus.Succeeded)
                    {
                        try {
                            enc.SetFileImpl(
                                task.RemoteUri.ToString(),
                                Path.GetDirectoryName(task.LocalPath),
                                task.MimeType,
                                Path.GetFileName(task.LocalPath)
                                );
                        } catch (Exception e) {
                            Log.Error(e);
                            enc.LastDownloadError = FeedDownloadError.DownloadFailed;
                            enc.DownloadStatus    = FeedDownloadStatus.DownloadFailed;
                            enc.Save();
                        }
                    }
                }
            }
        }
Beispiel #6
0
        private void DisconnectAction_Completed(object sender, TaskCompletedEventArgs e)
        {
            _logger.Info("OpenVpnConnection: Disconnect action completed");

            HandleTaskExceptionsIfAny(e.Task, "OpenVpnConnection: Disconnect action failed");

            OnStateChanged(VpnStatus.Disconnected);
        }
Beispiel #7
0
 private void taskm_Completed(object sender, TaskCompletedEventArgs <Tuple <int, DateTime> > e)
 {
     logger.Log(Resources.ConnectionCompleted, Category.Debug, Priority.None);
     Version    = e.Result.Item1;
     Date       = e.Result.Item2;
     Dlg.Result = true;
     Dlg.Close();
 }
Beispiel #8
0
        private void UserContext_TaskCompleted(object sender, TaskCompletedEventArgs e)
        {
            var callbackInfo = new CallbackInfo()
            {
                Index = this.index++, SignatureDate = e.SignatureDate
            };
            var taskIDs = e.TaskIDs;

            this.InvokeEvent(() => this.Callback?.OnTaskCompleted(callbackInfo, taskIDs));
        }
Beispiel #9
0
        private void ConnectAction_Completed(object sender, TaskCompletedEventArgs e)
        {
            _logger.Info("OpenVpnConnection: Connect action completed");

            HandleTaskExceptionsIfAny(e.Task, "OpenVpnConnection: Connection action failed");

            if (!e.Task.IsCanceled && !_disconnectAction.IsRunning)
            {
                OnStateChanged(VpnStatus.Disconnecting);
            }
        }
        public void SuccessfulTask()
        {
            Guid taskId = Guid.NewGuid();

            TaskCompletedEventArgs args = Helpers.WaitForEvent <TaskCompletedEventArgs>(
                TimeSpan.FromSeconds(10),
                handler => this.TaskExecutor.TaskCompleted += handler,
                () => this.TaskExecutor.StartTask(taskId, TaskPriority.Normal));

            Assert.AreEqual(taskId, args.TaskId);

            Assert.AreEqual(0, this.TaskExecutor.ActiveTasksCount);
        }
Beispiel #11
0
        public virtual void RaiseTaskCompleted()
        {
            Guid taskId = Guid.NewGuid();

            DateTime timestamp = DateTime.UtcNow;

            this.Receiver.SubscribeForChannels(MessageBusChannel.TaskCompleted);

            TaskCompletedEventArgs args = Helpers.WaitForEvent <TaskCompletedEventArgs>(
                this.Timeout,
                handler => this.Receiver.TaskCompleted += handler,
                () => this.Sender.NotifyTaskCompleted(taskId, timestamp, Guid.NewGuid(), false, TimeSpan.FromSeconds(1)));

            Assert.AreEqual(taskId, args.TaskId);
            Assert.AreEqual(timestamp, args.TimestampUtc);
            Assert.AreEqual(TimeSpan.FromSeconds(1), args.TotalCpuTime);
        }
Beispiel #12
0
        private void OnSyncCompleted(object sender, TaskCompletedEventArgs e)
        {
            if (e.Task.IsFaulted)
            {
                OnSyncStatusChanged(ProfileSyncStatus.Failed);
                _logger.Error(e.Task.Exception);
            }
            else
            {
                var status = _syncAction.Running
                    ? ProfileSyncStatus.InProgress
                    : _syncFailed
                        ? ProfileSyncStatus.Failed
                        : ProfileSyncStatus.Succeeded;

                OnSyncStatusChanged(status, status == ProfileSyncStatus.Failed ? _syncErrorMessage : null);
            }
        }
Beispiel #13
0
        private void taskmIsEmptyPage_Completed(object sender, TaskCompletedEventArgs <List <int> > e)
        {
            Text = string.Format(Resources.TextRead, GetMemoryType());
            logger.Log(string.Format(Resources.IsEmptyCompleted, GetMemoryType()), Category.Debug, Priority.None);
            taskm = new TaskManager <IMemory, double>((taskManager) =>
            {
                return((new ReadPageWorkerMaster(portName, settings.SettingsInfo.SerialPortSettings, logger,
                                                 settings.MemoryType, settings.SettingsInfo.Processor, e.Result)).Run(taskManager));
            });

            taskm.Canceled   += taskm_Canceled;
            taskm.Completed  += taskm_Completed;
            taskm.Faulted    += taskm_Faulted;
            taskm.Started    += taskm_Started;
            taskm.Progressed += taskm_Progressed;

            taskm.Start();
        }
Beispiel #14
0
        private void OnTaskCompleted(object sender, TaskCompletedEventArgs e)
        {
            TaskViewModel taskViewModel = this.taskProcessors
                                          .SelectMany(p => p.ActiveTasks)
                                          .Concat(this.pendingTasks)
                                          .FirstOrDefault(t => t.TaskId == e.TaskId);

            if (taskViewModel == null)
            {
                return;
            }

            App.Current.Dispatcher.InvokeAsync(() =>
            {
                taskViewModel.Percentage   = 100;
                taskViewModel.Status       = TaskStatus.Success.ToString();
                taskViewModel.CompletedUtc = e.TimestampUtc;
                taskViewModel.CpuTime      = e.TotalCpuTime;
            });
        }
        protected override void OnCompleted(TaskCompletedEventArgs e)
        {
            //if (e.Instance.IsStopPending)
            //    return;
            if (isSameObjectType)
            {
                return;
            }

            object value = e.Instance.Argument.UserState;

            if (value == null)
            {
                lastObjectType = null;
            }
            else
            {
                lastObjectType = value.GetType();
            }

            lastPropertyClass = pg.PropertyClass;

            if (!pg.IsGroupingEnabled)
            {
                pg.Dispatcher.Invoke(new Action(() => { pg.UpdateGridRowColumn(); }));
                pg.dataGrid.ItemsSource = pg._properties;
                return;
            }

            var metas = pg._properties.ToList();

            if (metas == null)
            {
                return;
            }

            OnCompletedGrouping(metas);
        }
Beispiel #16
0
 private void OnTaskCompleted(object sender, TaskCompletedEventArgs e)
 {
     if (TaskCompleted != null)
     {
         TaskCompleted(sender, e);
     }
 }
Beispiel #17
0
 private void taskm_Completed(object sender, TaskCompletedEventArgs<IMemory> e)
 {
     logger.Log(string.Format(Resources.ReadCompleted, GetMemoryType()), Category.Debug, Priority.None);
     Memory = e.Result;
     Dlg.Result = true;
     Dlg.Close();
 }
Beispiel #18
0
        private void taskmIsEmptyPage_Completed(object sender, TaskCompletedEventArgs<List<int>> e)
        {
            Text = string.Format(Resources.TextRead, GetMemoryType());
            logger.Log(string.Format(Resources.IsEmptyCompleted, GetMemoryType()), Category.Debug, Priority.None);
            taskm = new TaskManager<IMemory, double>((taskManager) =>
            {
                return (new ReadPageWorkerMaster(portName, settings.SettingsInfo.SerialPortSettings, logger,
                    settings.MemoryType, settings.SettingsInfo.Processor, e.Result)).Run(taskManager);
            });

            taskm.Canceled += taskm_Canceled;
            taskm.Completed += taskm_Completed;
            taskm.Faulted += taskm_Faulted;
            taskm.Started += taskm_Started;
            taskm.Progressed += taskm_Progressed;

            taskm.Start();
        }
Beispiel #19
0
 private void taskm_Completed(object sender, TaskCompletedEventArgs<byte> e)
 {
     logger.Log(string.Format(Resources.ReadLockCompleted, e.Result), Category.Debug, Priority.None);
     Locks = e.Result;
     Dlg.Result = true;
     Dlg.Close();
 }
Beispiel #20
0
 private void taskm_Completed(object sender, TaskCompletedEventArgs<bool> e)
 {
     RaiseCanExecuteChanged();
 }
Beispiel #21
0
 private void OnDisconnectActionCompleted(object sender, TaskCompletedEventArgs e)
 {
     _logger.Info("[WireGuardConnection] Disconnect action completed");
     InvokeStateChange(VpnStatus.Disconnected, _lastVpnError);
     _lastVpnError = VpnError.None;
 }
Beispiel #22
0
 private void OnConnectActionCompleted(object sender, TaskCompletedEventArgs e)
 {
     _logger.Info("[WireGuardConnection] Connect action completed");
 }
Beispiel #23
0
 protected virtual void OnTaskCompleted(TaskCompletedEventArgs e)
 {
     this.taskCompleted?.Invoke(this, e);
 }
Beispiel #24
0
 private void taskm_Completed(object sender, TaskCompletedEventArgs<bool> e)
 {
     logger.Log(Resources.ResetCompleted, Category.Debug, Priority.None);
     Dlg.Result = true;
     Dlg.Close();
 }
Beispiel #25
0
 private void ProgressChanged( object sender, TaskCompletedEventArgs e )
 {
     if ( e != null)
     {
         if ( OperationLeft >= e.TaskCompleted )
         {
             Interlocked.Add(ref OperationLeft, - e.TaskCompleted);
         }
         else throw new ConstraintException( " wrong number of operation " );
     }
 }
Beispiel #26
0
 private void ProgressOnTaskCompleted(object sender, TaskCompletedEventArgs args)
 {
     // task may be rescheduled
     scheduled = false;
 }
Beispiel #27
0
 private void taskm_Completed(object sender, TaskCompletedEventArgs <bool> e)
 {
     logger.Log(Resources.ResetCompleted, Category.Debug, Priority.None);
     Dlg.Result = true;
     Dlg.Close();
 }
Beispiel #28
0
 private void taskm_Completed(object sender, TaskCompletedEventArgs <bool> e)
 {
     RaiseCanExecuteChanged();
 }
 private void taskm_Completed(object sender, TaskCompletedEventArgs<Tuple<int, DateTime>> e)
 {
     logger.Log(Resources.ConnectionCompleted, Category.Debug, Priority.None);
     Version = e.Result.Item1;
     Date = e.Result.Item2;
     Dlg.Result = true;
     Dlg.Close();
 }