Hi Oga,
It sounds like the piece you are missing is something like this....
When the Background Thread (the database work) in 'form1' is done, you
will need to fire an event. First, create a delegate to handle the
closing of 'form2' by a Background Thread, and the Event that will be
fired:
public delegate void Form1DoneDelega te();
public event Form1DoneDelega te WorkFinishedEve nt;
Then, subscribe to that Event in 'form1':
Form1.WorkFinis hedEvent+= new Form1DoneDelega te (CloseForm2);
Finally, create the 'CloseForm2' method (it needs to close 'form2', or
whatever) - something like this:
private void CloseForm2()
{
if (Form2.InvokeRe quired) //Make sure we are on the main UI
thread
{
BeginInvoke(new Form1DoneDelega te(CloseForm2)) ;
}
else
{
Form2.Close();
}
}
Note that the number of arguments for the delegate (Form1DoneDeleg ate)
and method (CloseForm2) match - they are zero. You can add some if you
need to.
Hope this helps.
Dave
bi*****@gmail.c om wrote:
I need help with background worker and form
I have a class (form1) that works with database. I need this:
-Show form2 while form1 is geting data from database
-When form1 is done, close form2, proced working form1
I try these things with thread but a can not do it
I try it with background worker, but I
dont know how:(
does enyone knows how to do this thing.
Thanx in advance
Oga