public SchedulerTask RunTask(Func<TaskFactory, SchedulerTask> fn) { progressBar1.Value = 0; label1.Text = richTextBox1.Text = ""; var factory = ProgramContext.Container.Resolve<TaskFactory>(); task = fn(factory); task.TaskStarted += (t) => { }; task.TaskFinished += (t) => { }; task.ScriptStarted += (t, s) => { }; task.ScriptFinished += (t, s) => { }; task.ScriptCustomEvent += (t, s, o) => { }; task.Progress.Update += (p) => this.Invoke(new Action( () => { label1.Text = p.Message; progressBar1.Value = p.Completeness; richTextBox1.Text += p.Message + Environment.NewLine; richTextBox1.SelectionStart = richTextBox1.Text.Length; richTextBox1.ScrollToCaret(); })); var asyncRunner = new Action( () => { factory.RunTaskUntilFinished(task); if (OnTaskComplete != null) OnTaskComplete(this, EventArgs.Empty); }); asyncRunner.BeginInvoke(null, null); return task; }
protected virtual void OnScriptFinished(SchedulerTask task, ISchedulerTaskScript script) { if (ScriptFinished != null) ScriptFinished(task, script); }
protected void OnTaskFinished(SchedulerTask task) { if (TaskFinished != null) TaskFinished(task); }
protected void OnScriptCustomEvent(SchedulerTask task, ISchedulerTaskScript script, object input) { if (ScriptCustomEvent != null) ScriptCustomEvent(task, script, input); }