Originally Posted by
LizR
This is the bit that worries me
Form2 form1=new Form2();
Form2 form2=new Form2();
Form2 form3=new Form2();
if your worker makes those forms then how is it sure which form its using?
well the first background worker
this code is in main:
BackgroundWorker bw1 = new BackgroundWorker();
bw1.DoWork += new DoWorkEventHandler(BWClass1.bw1_DoWork);
this code down is in BWClass1!!!!
public static Form2 form1;
public static void bw1_DoWork(object sender, DoWorkEventArgs e)
{
form1=new Form2(0);
}
this code down is in BWClass2!!!!
the second background worker those the same but for
public static void bw2_DoWork(object sender, DoWorkEventArgs e)
{
form2=new Form2(1);
}
each background worker is using his one instance in function.
in constructor i am passing an argument Form2(1) which says which form should he draw and which form to update
i am doing the update of instance of Form2 in each backgroundworker for each form with get,set properties.For an example:
backgroundworker1:
form1.TEMP_PROFIL1 =temperature1;
form1.TEMP_PROFIL2 =temperature2;
form1.SREDNJA_TEMP = average_temp;
form1.MAKS_TEMP = max_temp;
backgroundworker2:
form2.TEMP_PROFIL1 =temperature1;
form2.TEMP_PROFIL2 =temperature2;
form2.SREDNJA_TEMP = average_temp;
form2.MAKS_TEMP = max_temp;
after i do my update I call an event which will draw an panel on specified Form2 instance
form1.clicked();
or
form2.clicked();
the function of the event is declared in Form2 class!!!
Hopes this clarifies a bit more!!!