protected override void OnActivated(EventArgs e) { base.OnActivated(e); // Make sure we ONLY run the simulation once.. if (!_simulation_ran) { _simulation_ran = true; _simulation = new HydroSharedAddIn.excel.RoutingSimulation(); _simulation.DoEstablishWorksheetNames(_simulation.SimulationWorksheetNames); // start the simulation... RunAsynch(); } }
protected override void OnActivated(EventArgs e) { base.OnActivated(e); if (!_has_run) { _has_run = true; _simulation = new HydroSharedAddIn.excel.RoutingSimulation(); _simulation.DoEstablishWorksheetNames(_simulation.SimulationWorksheetNames); // start the simulation... this.toolStripStatusLabel1.Text = "begin simulations"; this.buttonOK.Enabled = false; buttonOK.DialogResult = DialogResult.OK; if (true) { Run(); _simulation = null; _workbook = null; GC.Collect(); lock (this) { buttonOK.Enabled = true; currentSimulationLabel1.Text = "Successfully completed all simulations"; toolStripProgressBar1.Value = toolStripProgressBar1.Minimum; toolStripStatusLabel1.Text = "done"; } } else { RunAsynch(); } } }
void AsyncCallback(IAsyncResult ar) { //MessageBox.Show("received asycn callback" + Environment.NewLine + "will now terminate process thread..."); // Simulation has completed _processAsync.EndInvoke(_asyncResult); //MessageBox.Show("async process has ended."); _processAsync = null; _simulation = null; //_workbook = null; GC.Collect(); lock (this) { buttonOK.Enabled = true; currentSimulationLabel1.Text = "Successfully completed all simulations"; toolStripProgressBar1.Value = toolStripProgressBar1.Minimum; toolStripStatusLabel1.Text = "done"; } }
private void ProcessAll(Microsoft.Office.Interop.Excel.Workbook wb) { try { toolStripStatusLabel1.Text = "running simulation"; currentSimulationLabel1.Text = "starting simulation..."; // excel.RoutingSimulation rs = new HydroSharedAddIn.excel.RoutingSimulation(_workbook); //rs.Run(); _simulation.Run(); _simulation = null; _workbook = null; GC.Collect(); toolStripStatusLabel1.Text = "done"; buttonOK.Enabled = true; } catch (Exception e) { // this.listView1.Visible = false; //this._statusBox.Visible = true; //_statusBox.Text = e.ToString(); System.Windows.Forms.MessageBox.Show(e.ToString()); toolStripStatusLabel1.Text = "error"; } }