Winform doesnot show up when i tried to open from a backgroundworker_RunWorkerCompleted event?
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
It may be that BackgroundWorker OnWorkCompleted throws cross-thread exception ? Try UI handling in another thread, check this.IsInvokeRequired property and use this.Invoke(...)
精彩评论