Ejemplo n.º 1
0
			///////////////////////////////
			
			public void DoTask ()
			{
				if (! cancelled) {
					if (Debug)
						Logger.Log.Debug ("Starting task {0}", Tag);
					child_task_group = null;
					Reschedule = false;
					TouchAllTaskGroups ();

					Stopwatch sw = new Stopwatch ();
					sw.Start ();
						
					try {
						DoTaskReal ();
					} catch (Exception ex) {
						misfires ++;
						Logger.Log.Warn (ex,
								 "Caught exception in DoTaskReal\n" +
								 "        Tag: {0}\n" +
								 "    Creator: {1}\n" +
								 "Description: {2}\n" +
								 "   Priority: {3} ({4})", 
								 Tag, Creator, Description, Priority, SubPriority);
						if (misfires >= MAX_TASK_EXCEPTION) {
							Log.Warn ("More than {5} exceptions in DoTaskReal. Disabling further execution of task:\n" +
								 "        Tag: {0}\n" +
								 "    Creator: {1}\n" +
								 "Description: {2}\n" +
								 "   Priority: {3} ({4})", 
								 Tag, Creator, Description, Priority, SubPriority, MAX_TASK_EXCEPTION);
							Cancel ("Exceptions in DoTaskReal");
						}
					}
					sw.Stop ();
					if (Debug)
						Logger.Log.Debug ("Finished task {0} in {1}", Tag, sw);

					if (cancelled) {
						return;
					} else if (Reschedule) {
						++count;
						if (Debug)
							Log.Debug ("Rescheduling task {0}", Tag);
						scheduler.Add (this); // re-add ourselves
					} else {
						DecrementAllTaskGroups ();
						scheduler = null;
					}
				}
			}
Ejemplo n.º 2
0
			///////////////////////////////
			
			public void SpawnChild (Task child_task)
			{
				if (child_task_group == null)
					child_task_group = new TaskGroupPrivate ("Children of " + Tag, null, null);
				child_task.AddTaskGroup (child_task_group);
				child_task.Source = this.Source;
				scheduler.Add (child_task);
			}