public void Enqueue(IActivity activity, Action <IActivity> todo)
        {
            var task = new ASynchTask(activity, todo);

            task.TaskCompleted += TaskTaskCompleted;

            todoTasks.Add(task);
            activities.Add(activity);
            Debug.WriteLine(string.Format("Enqueued activity {0}", activity.Name));
            StartTaskIfPossible();
            //TODO: it might already be running so running would not be changed.
            //fix and review
            OnIsRunningChanged();
        }
        private void OnTaskCompleted(ASynchTask sender)
        {
            if (!sender.TaskCompletedSuccesFully)
            {
                if (String.IsNullOrEmpty(sender.Activity.Name))
                {
                    log.ErrorFormat("An error occured while running a background activity.");
                }
                else
                {
                    log.ErrorFormat("An error occured while running activity {0}", sender.Activity.Name);
                }
            }

            if (ActivityCompleted != null)
            {
                ActivityCompleted(this, new ActivityEventArgs(sender.Activity));
            }
        }
Beispiel #3
0
 private void OnTaskCompleted(ASynchTask sender)
 {
     if (!sender.TaskCompletedSuccesFully)
     {
         if (String.IsNullOrEmpty(sender.Activity.Name))
         {
             log.ErrorFormat("An error occured while running a background activity.");    
         }
         else
         {
             log.ErrorFormat("An error occured while running activity {0}",sender.Activity.Name);    
         }
         
     }
         
     if (ActivityCompleted != null)
     {
         ActivityCompleted(this, new ActivityEventArgs(sender.Activity));
     }
 }
Beispiel #4
0
        private void CleanUp(ASynchTask task)
        {
            task.TaskCompleted -= TaskTaskCompleted;

            task.Dispose();
        }
Beispiel #5
0
 public void Enqueue(IActivity activity, Action<IActivity> todo)
 {
     var task = new ASynchTask(activity, todo);
     task.TaskCompleted += TaskTaskCompleted;
     
     todoTasks.Add(task);
     activities.Add(activity);
     Debug.WriteLine(string.Format("Enqueued activity {0}", activity.Name));
     StartTaskIfPossible();
     //TODO: it might already be running so running would not be changed.
     //fix and review
     OnIsRunningChanged();
 }