Exemplo n.º 1
0
        private bool InternalInvokeTask(string TaskName, TaskControlAction value, string Category, string TaskHandler)
        {
            var ShouldEnqueueTask = false;

            if (!this.PersistanceDisabled)
            {
                if (this.Stopwatch.ElapsedMilliseconds > Timeout)
                {
                    ShouldEnqueueTask = true;
                }
            }

            if (ShouldEnqueueTask)
            {
                CountTaskEnqeued++;

                if (this.TaskEnqeued != null)
                {
                    this.TaskEnqeued(TaskName);
                }

                return(false);
            }


            if (this.TaskStarted != null)
            {
                this.TaskStarted(TaskName);
            }

            var c = new TaskControl();

            var s = new Stopwatch();

            s.Start();
            try
            {
                value(c);
            }
            catch
            {
                // in case of errors we will mark this workflow not to be persisted anymore...
                PersistanceDisabled = true;
                // we might want to store the current exception...
                throw new InvalidOperationException();
            }

            s.Stop();

            if (c.Fault)
            {
                if (this.TaskFault != null)
                {
                    this.TaskFault(TaskName);
                }

                this.ElapsedAtFault += (uint)s.ElapsedMilliseconds;

                return(true);
            }

            this.Content.Add(TaskHandler);
            var i = new TaskInfo();

            AddTaskInfo(TaskName, Category, i);
            i.Elapsed.ValueUInt32 = (uint)s.ElapsedMilliseconds;

            if (this.TaskCompleted != null)
            {
                this.TaskCompleted(TaskName, s.Elapsed);
            }

            return(false);
        }
		private bool InternalInvokeTask(string TaskName, TaskControlAction value, string Category, string TaskHandler)
		{
            var ShouldEnqueueTask = false;

			if (!this.PersistanceDisabled)
				if (this.Stopwatch.ElapsedMilliseconds > Timeout)
				{
                    ShouldEnqueueTask = true;
				}

            if (ShouldEnqueueTask)
            {
                CountTaskEnqeued++;

                if (this.TaskEnqeued != null)
                    this.TaskEnqeued(TaskName);

                return false;
            }


			if (this.TaskStarted != null)
				this.TaskStarted(TaskName);

			var c = new TaskControl();

			var s = new Stopwatch();
			s.Start();
			try
			{
				value(c);
			}
			catch 
			{
				// in case of errors we will mark this workflow not to be persisted anymore...
				PersistanceDisabled = true;
				// we might want to store the current exception...
				throw new InvalidOperationException();
			}

			s.Stop();

			if (c.Fault)
			{
				if (this.TaskFault != null)
					this.TaskFault(TaskName);

				this.ElapsedAtFault += (uint)s.ElapsedMilliseconds;

				return true;
			}

			this.Content.Add(TaskHandler);
			var i = new TaskInfo();
			AddTaskInfo(TaskName, Category, i);
			i.Elapsed.ValueUInt32 = (uint)s.ElapsedMilliseconds;

			if (this.TaskCompleted != null)
				this.TaskCompleted(TaskName, s.Elapsed);

			return false;
		}