protected override void OnLoad(EventArgs e) { base.OnLoad(e); if (this.DesignMode) { return; } // do we run on load? if (this.RunOnLoad != null) { OperationDialogProcess toRun = this.RunOnLoad; _runOnLoad = null; // run... this.Run(toRun); } }
/// <summary> /// Runs the supplied process. /// </summary> /// <param name="process"></param> public void Run(OperationDialogProcess process) { if (process == null) { throw new ArgumentNullException("process"); } // check... if (process.Context == null) { throw new InvalidOperationException("process.Context is null."); } // mbr - 2008-11-27 - if it doesn't have an operation, give it us... if (process.Context.InnerOperation == null || process.Context.DefaultInnerOperationUsed) { process.Context.InnerOperation = this; } // load called? if (!(this.LoadCalled)) { _runOnLoad = process; return; } // thread? if (_thread != null) { throw new InvalidOperationException("A thread is already running."); } // create... _thread = new ThreadUIHelper(this, this); // mbr - 10-05-2007 - changed this to create a log file if we haven't been given one explicitly... if (process.Context.HasInnerLog) { _thread.BoundLog = process.Context.InnerLog; } else { // log... FileLog log = LogSet.CreateFileLogger(process.GetType().Name, FileLoggerFlags.AddDateToFileName | FileLoggerFlags.EnsureNewFile | FileLoggerFlags.OwnFolder); if (log == null) { throw new InvalidOperationException("log is null."); } // set... _thread.BoundLog = log; } // events... _thread.Failed += new System.Threading.ThreadExceptionEventHandler(_thread_Failed); _thread.Succeeded += new ResultEventHandler(_thread_Succeeded); // run... _thread.RunAsync(process, "Run"); }