private void Run(DatabaseUpdateOperation type) { // check... if (_thread != null) { throw new InvalidOperationException("A database update operation is already running."); } // create... ConnectionSettings settings = Database.DefaultConnectionSettings; if (settings == null) { throw new InvalidOperationException("settings is null."); } // create... _thread = new ThreadUIHelper(this, this.operation); _thread.ThreadStarted += new EventHandler(_thread_ThreadStarted); _thread.ThreadFinished += new EventHandler(_thread_ThreadFinished); _thread.Failed += new System.Threading.ThreadExceptionEventHandler(_thread_Failed); _thread.RunAsync(this, "RunInternal", type); // reset... this.RefreshButtons(); }
/// <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"); }