//windows forms
//c#
UserControl1 SortzTextAndProg = new UserControl1();
public void BubleSortMethod()
{
Controls.Add(SortzTextAndProg);
SortzTextAndProg.Left = 10;
SortzTextAndProg.Top = 100;
int temp = 0, k = 1;
KindsOfSorting Obj = new KindsOfSorting();
while (Obj.NumberOfSwapzInBubble >= temp)
{
if (Obj.NumberOfSwapzInBubble == 0)
{
temp += 2;
}
Obj.BublSort(ref ArryBub);
Thread.Sleep(1000);
for (int i = 0; i < 15; i++)
{
SortzTextAndProg.rtxSortingResult.AppendText("\t" + ArryBub[k, i]);
}
/*Keep a Break Point ,U can see the values of rtxSortingResult gettinf appened*/
SortzTextAndProg.pbSortz.Step = 30;
SortzTextAndProg.pbSortz.PerformStep();
SortzTextAndProg.rtxSortingResult.AppendText("\n" + "After" + " " + temp++ + " " + "Swap" + "\n");
k++;
}
}
private void allTheSortsToolStripMenuItem_Click(object sender, EventArgs e)
{
Form1 Fobj = new Form1();
Thread ThreadBub = new Thread(new ThreadStart(Fobj.BubleSortMethod));
ThreadBub.Start();
}
in the above code for windows forms......where in
UserControl1 is a usercontrol created with a rich text box name rtxSortingResult and a progress bar name pbSortz
in my dll i have a method called BubleSortMethod
which has 2 dimentional array which is ArryBub
i create a thread for this sort
when the thread is running i can see the values of rtxSortingResult and pbSortz getting changed
after the thread is over when the control returns to the Main ........the object dies and the User control is not displaying
why is this?