New forms are causing my GUI to freeze up

  • Thread starter Thread starter Btb4198
  • Start date Start date
B

Btb4198

Guest
So my GUI is freezing up because of this function:


void callingHistogram_Form( double[] TV, double[] SinusoidalCurveFitting)
{
Histogram_Form f = new Histogram_Form();
double[] DL = new double[1];
DL[0] = BaseLine_Dark;
f.DarkLight_values = DL;
f.BrightLight_values = BaseLineBright.ToArray();
f.Raw_value = Raw.ToArray();
f.Transmission_values =TV ;
f.SinusoidalCurveFitting = SinusoidalCurveFitting;
f.step_Pass = stepPass;
f.start_Step = startStep;
f.stop_Step = stopStep;
f.ShowDialog();
f.Hide();
f.Close();
f = null;
}



so what is happening is, I click a button and the software run this routine in a new thread and at the end of it, is calls that function to display the information in a new Form that is just a graph. Now depending on what kind of routine you are doing, you can have multiple graphs and the function is in a for loop :

for (int i = 0; i < stIRList.Count; i++)
{



try
{
if (SinusoidalCurveCB.Checked)
{
callingHistogram_Form(Transmission.ToArray(), await SinusoidalCurveFitting(TP, TS));
}
else
callingHistogram_Form(Transmission.ToArray());

}
catch (Exception err)
{
AppendDisplayBox(err.Message);

}


}


if I removed this function then the program run fine.


but with that function it seem to work fine for the 1st run but if I display too many graphs the second run, the software will freeze up.

Also, I might can do a few runs before it freezes up, it just depending on how many graphs I display.


so what I am doing wrong ?

private void Histogram_Form_Load(object sender, EventArgs e)
{
Console.WriteLine("Load Forum");
try
{

PlotSpectrum();


}
catch(Exception err)
{
Console.WriteLine(err.Message);
MessageBox.Show(err.ToString());
}
Console.WriteLine("Load Forum");
}


private void closeToolStripMenuItem_Click(object sender, EventArgs e)
{
this.Close();
}

Continue reading...
 
Back
Top