Beispiel #1
0
        protected virtual void OnDispose(bool disposing)
        {
            if (disposed)
            {
                return;
            }
            disposed = true;

            if (parentMonitor != null && firstCachedLogChunk != null)
            {
                parentMonitor.DumpLog(firstCachedLogChunk);
                firstCachedLogChunk = null;
            }

            var t = parentRootTask;

            parentRootTask = null;
            while (currentTask != t && currentTask != null)
            {
                EndTask();
            }

            if (context != null)
            {
                context.Post((o) => ((ProgressMonitor)o).OnCompleted(), this);
            }
            else
            {
                OnCompleted();
            }

            if (followerMonitors != null)
            {
                foreach (var m in followerMonitors)
                {
                    m.Dispose();
                }
            }
            if (disposeCallbacks != null)
            {
                foreach (var c in disposeCallbacks.ToArray())
                {
                    c();
                }
                disposeCallbacks = null;
            }
        }
        public virtual void Dispose()
        {
            if (disposed)
            {
                return;
            }
            disposed = true;

            if (parentMonitor != null && firstCachedLogChunk != null)
            {
                parentMonitor.DumpLog(firstCachedLogChunk);
                firstCachedLogChunk = null;
            }

            var t = parentRootTask;

            parentRootTask = null;
            while (currentTask != t && currentTask != null)
            {
                EndTask();
            }

            if (context != null)
            {
                context.Post((o) => OnCompleted(), null);
            }
            else
            {
                OnCompleted();
            }

            if (slaveMonitors != null)
            {
                foreach (var m in slaveMonitors)
                {
                    m.Dispose();
                }
            }
            if (disposeCallbacks != null)
            {
                foreach (var c in disposeCallbacks.ToArray())
                {
                    c();
                }
                disposeCallbacks = null;
            }
        }
Beispiel #3
0
        public IDisposable BeginTask(string name, int totalWork)
        {
            var t = new ProgressTask(this, name, totalWork);

            if (openStepWork != -1)
            {
                t.StepWork = openStepWork;

                openStepWork = -1;
            }
            if (currentTask == null)
            {
                rootTask = t;
            }
            else
            {
                currentTask.AddChild(t);
            }

            currentTask = t;

            //	if (name != null) {
            if (context != null)
            {
                context.Post((o) => {
                    var(mon, task) = (ValueTuple <ProgressMonitor, ProgressTask>)o;
                    mon.OnBeginTask(task.Name, task.TotalWork, task.StepWork);
                }, (this, t));
            }
            else
            {
                OnBeginTask(name, totalWork, t.StepWork);
            }
            //	}

            ReportProgressChanged();

            if (followerMonitors != null)
            {
                foreach (var m in followerMonitors)
                {
                    m.BeginTask(name, totalWork);
                }
            }
            return(t);
        }
        public IDisposable BeginTask(string name, int totalWork)
        {
            var t = new ProgressTask(this, name, totalWork);

            if (openStepWork != -1)
            {
                t.StepWork = openStepWork;

                openStepWork = -1;
            }
            if (currentTask == null)
            {
                rootTask = t;
            }
            else
            {
                currentTask.AddChild(t);
            }

            currentTask = t;

            //	if (name != null) {
            if (context != null)
            {
                context.Post((o) => OnBeginTask(name, totalWork, t.StepWork), null);
            }
            else
            {
                OnBeginTask(name, totalWork, t.StepWork);
            }
            //	}

            ReportProgressChanged();

            if (slaveMonitors != null)
            {
                foreach (var m in slaveMonitors)
                {
                    m.BeginTask(name, totalWork);
                }
            }
            return(t);
        }
Beispiel #5
0
        public void EndTask()
        {
            if (currentTask != null && currentTask != parentRootTask)
            {
                openStepWork = -1;
                var t = currentTask;
                currentTask = t.ParentTask;
                if (currentTask == null)
                {
                    rootTask = null;
                }
                t.SetComplete();
                //		if (t.Name != null) {
                if (context != null)
                {
                    context.Post((o) => {
                        var(mon, task) = (ValueTuple <ProgressMonitor, ProgressTask>)o;
                        mon.OnEndTask(task.Name, task.TotalWork, task.StepWork);
                    }, (this, t));
                }
                else
                {
                    OnEndTask(t.Name, t.TotalWork, t.StepWork);
                }
                //		}
            }
            else
            {
                LoggingService.LogError("Task not started");
            }

            ReportProgressChanged();

            if (followerMonitors != null)
            {
                foreach (var m in followerMonitors)
                {
                    m.EndTask();
                }
            }
        }
        public void EndTask()
        {
            if (currentTask != null && currentTask != parentRootTask)
            {
                openStepWork = -1;
                var t = currentTask;
                currentTask = t.ParentTask;
                if (currentTask == null)
                {
                    rootTask = null;
                }
                t.SetComplete();
                //		if (t.Name != null) {
                if (context != null)
                {
                    context.Post((o) => OnEndTask(t.Name, t.TotalWork, t.StepWork), null);
                }
                else
                {
                    OnEndTask(t.Name, t.TotalWork, t.StepWork);
                }
                //		}
            }
            else
            {
                LoggingService.LogError("Task not started");
            }

            ReportProgressChanged();

            if (slaveMonitors != null)
            {
                foreach (var m in slaveMonitors)
                {
                    m.EndTask();
                }
            }
        }
		void SetChildComplete (ProgressTask child)
		{
			child.ParentTask = null;
			lock (childrenTasks) {
				if (child.HasStepWork)
					currentWork += child.StepWork;
				childrenTasks.Remove (child);
			}
			UpdateProgressFromChildren ();
		}
		internal void AddChild (ProgressTask task)
		{
			task.ParentTask = this;
			lock (childrenTasks)
				childrenTasks.Add (task);
		}
		internal void EndTask (ProgressTask task)
		{
			while (currentTask != null && currentTask != task)
				EndTask ();
			EndTask ();
		}
		public void EndTask ()
		{
			if (currentTask != null && currentTask != parentRootTask) {
				openStepWork = -1;
				var t = currentTask;
				currentTask = t.ParentTask;
				if (currentTask == null)
					rootTask = null;
				t.SetComplete ();
		//		if (t.Name != null) {
					if (context != null)
						context.Post ((o) => OnEndTask (t.Name, t.TotalWork, t.StepWork), null);
					else
						OnEndTask (t.Name, t.TotalWork, t.StepWork);
		//		}
			} else
				LoggingService.LogError ("Task not started");

			ReportProgressChanged ();

			if (followerMonitors != null) {
				foreach (var m in followerMonitors)
					m.EndTask ();
			}
		}
		public IDisposable BeginTask (string name, int totalWork)
		{
			var t = new ProgressTask (this, name, totalWork);
			if (openStepWork != -1) {
				t.StepWork = openStepWork;
				openStepWork = -1;
			}
			if (currentTask == null)
				rootTask = t;
			else
				currentTask.AddChild (t);

			currentTask = t;

		//	if (name != null) {
				if (context != null)
					context.Post ((o) => OnBeginTask (name, totalWork, t.StepWork), null);
				else
					OnBeginTask (name, totalWork, t.StepWork);
		//	}

			ReportProgressChanged ();

			if (followerMonitors != null) {
				foreach (var m in followerMonitors)
					m.BeginTask (name, totalWork);
			}
			return t;
		}
		public virtual void Dispose ()
		{
			if (disposed)
				return;
			disposed = true;

			if (parentMonitor != null && firstCachedLogChunk != null) {
				parentMonitor.DumpLog (firstCachedLogChunk);
				firstCachedLogChunk = null;
			}

			var t = parentRootTask;
			parentRootTask = null;
			while (currentTask != t && currentTask != null)
				EndTask ();

			if (context != null)
				context.Post ((o) => OnCompleted (), null);
			else
				OnCompleted ();

			if (followerMonitors != null) {
				foreach (var m in followerMonitors)
					m.Dispose ();
			}
			if (disposeCallbacks != null) {
				foreach (var c in disposeCallbacks.ToArray ())
					c ();
				disposeCallbacks = null;
			}
		}
		void SetParentTask (ProgressMonitor parent, ProgressTask task, int work)
		{
			parentMonitor = parent;
			currentTask = parentRootTask = task;
			openStepWork = work;
			ReportGlobalDataToParent = true;
		}
Beispiel #14
0
 internal void AddChild(ProgressTask task)
 {
     task.ParentTask = this;
     lock (childrenTasks)
         childrenTasks.Add(task);
 }