Exemple #1
0
        void OnTaskToggled(object sender, Gtk.ToggledArgs args)
        {
            Logger.Debug("OnTaskToggled");
            Gtk.TreeIter iter;
            Gtk.TreePath path = new Gtk.TreePath(args.Path);
            if (!Model.GetIter(out iter, path))
            {
                return;                 // Do nothing
            }
            ITask task = Model.GetValue(iter, 0) as ITask;

            if (task == null)
            {
                return;
            }

            // remove any timer set up on this task
            InactivateTimer.CancelTimer(task);

            if (task.State == TaskState.Active)
            {
                bool showCompletedTasks =
                    Application.Preferences.GetBool(
                        Preferences.ShowCompletedTasksKey);

                // When showCompletedTasks is true, complete the tasks right
                // away.  Otherwise, set a timer and show the timer animation
                // before marking the task completed.
                if (showCompletedTasks)
                {
                    task.Complete();
                    ShowCompletedTaskStatus();
                }
                else
                {
                    task.Inactivate();

                    // Read the inactivate timeout from a preference
                    int timeout =
                        Application.Preferences.GetInt(Preferences.InactivateTimeoutKey);
                    Logger.Debug("Read timeout from prefs: {0}", timeout);
                    InactivateTimer timer =
                        new InactivateTimer(this, iter, task, (uint)timeout);
                    timer.StartTimer();
                    toggled = true;
                }
            }
            else
            {
                status = Catalog.GetString("Action Canceled");
                TaskWindow.ShowStatus(status);
                task.Activate();
            }
        }
        /// <summary>
        /// Marks a task complete
        /// </summary>
        /// <param name="id">
        /// A <see cref="System.String"/> for the ID of the task
        /// </param>
        public void MarkTaskAsCompleteById(string id)
        {
            ITask task = GetTaskById(id);

            if (task == null)
            {
                return;
            }

            if (task.State == TaskState.Active)
            {
                // Complete immediately; no timeout or fancy
                // GUI stuff.
                task.Complete();
            }
        }
Exemple #3
0
 protected virtual void RunTask(object item)
 {
     Recorder.Trace(2L, TraceType.InfoTrace, new object[]
     {
         "Executor.RunTask Item:",
         item,
         "IsCancelled:",
         this.IsCancelled
     });
     if (!this.IsCancelled)
     {
         ITask task = null;
         try
         {
             long timestamp = this.Policy.Recorder.Timestamp;
             task       = (Activator.CreateInstance(this.TaskType) as ITask);
             task.State = new SearchTaskContext
             {
                 TaskContext = this.TaskContext,
                 Executor    = this,
                 Item        = item
             };
             task.Execute(this.defaultQueueDelay, this.defaultTimeout);
             task.Complete(this.defaultQueueDelay, this.defaultTimeout);
             long num = this.Policy.Recorder.Timestamp - timestamp;
             Interlocked.Increment(ref this.itemCount);
             Interlocked.Add(ref this.totalDuration, num);
             IList list = item as IList;
             int   num2 = 1;
             if (list != null)
             {
                 num2 = list.Count;
             }
             this.batchDurations.Add(new Tuple <long, long, long>(timestamp, num, (long)num2));
         }
         catch (SearchException ex)
         {
             if (task != null)
             {
                 task.Cancel();
             }
             this.Cancel(ex);
             Recorder.Trace(2L, TraceType.ErrorTrace, "Executor.RunTask Failed Error:", ex);
         }
     }
 }
Exemple #4
0
            private bool CompleteTask()
            {
                if (!Paused)
                {
                    GLib.Source.Remove(pulseTimeoutId);
                    if (timers.ContainsKey(task.TimerID))
                    {
                        timers.Remove(task.TimerID);
                    }

                    if (task.State != TaskState.Inactive)
                    {
                        return(false);
                    }

                    task.Complete();
                    ShowCompletedTaskStatus();
                    tree.Refilter();
                    return(false);                    // Don't automatically call this handler again
                }

                return(true);
            }