views:

47

answers:

1

Hi the detail of my action is i have a winform which contains only progress bar which i made to do some calculations and stored the final value in db.for this i used progress bar and backgroundworker thread. i am doing all calculation in backgroundworker thread event doWork event. When backgroundworker is finish it calls RunWorkerCompleted event, in which i am trying to open another winform. The problem is that winform doesnt get visible.

private void backgroundWorker1_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) 
{ 
    if (!string.IsNullOrEmpty(click)) { 
        if (click == "sales") { 
           Sales sales = new Sales(); 
           sales.MdiParent = mdiStockApp.mdi; 
           sales.Show(); 
           sales.Activate(); 
        } 
    } 
}

this is the RunWorkerCompleted event in which i am trying to open another event. just now i tried with form.Activate() too but still no

A: 

It may be that BackgroundWorker OnWorkCompleted throws cross-thread exception ? Try UI handling in another thread, check this.IsInvokeRequired property and use this.Invoke(...)

tom3k
i tried with this.IsInvokeRequired which returns me false.
Nipun
when i call sales.Show() and try to debug it never goes to Sales form. any reasons???
Nipun