private void ForwardCalculateThread(object obj) { Invoke(new EventHandler(() => { DigitalModelProgressBar.Visible = true; DigitalModelProgressBar.Style = ProgressBarStyle.Marquee; progressTip.Visible = true; progressTip.Text = "正在计算..."; })); double Nz = zedGraphControl.GraphPane.YAxis.Scale.Max - zedGraphControl.GraphPane.YAxis.Scale.Min; double Nx = zedGraphControl.GraphPane.XAxis.Scale.Max - zedGraphControl.GraphPane.XAxis.Scale.Min; ForwardCalculationForm.DataChangeEventArgs args = obj as ForwardCalculationForm.DataChangeEventArgs; float[,] record = new float[(int)Nx, args.Time];; unsafe { float[,] arr = Gv; int row = arr.GetUpperBound(0) + 1; int col = arr.GetUpperBound(1) + 1; fixed(float *fp = arr) { float *[] farr = new float *[row]; for (int i = 0; i < row; i++) { farr[i] = fp + i * col; } fixed(float **v = farr) { Algorithm algorithm = new Algorithm(args.Time, (int)Nx, (int)Nz, args.Sx, args.Sz, v); algorithm.Calculate(args.File1, args.File2, args.File3); for (int i = 0; i < args.Time; i++) { for (int j = 0; j < Nx; j++) { record[j, i] = algorithm.Record[j][i]; } } } } } Invoke(new EventHandler(() => { DigitalModelProgressBar.Visible = false; progressTip.Visible = false; DigitalModelProgressBar.Style = ProgressBarStyle.Blocks; if (record != null) { OpenChartForm(record); } })); }
private void ForwardCalculate(object sender, ForwardCalculationForm.DataChangeEventArgs args) { Thread thread = new Thread(ForwardCalculateThread) { IsBackground = true }; thread.SetApartmentState(ApartmentState.STA); thread.Start(args); ForwardCalculationForm forwardCalculationForm = (ForwardCalculationForm)sender; forwardCalculationForm.Close(); }