Hello I have a form that is mdi container, I drop a menuitem, when I click the menuitem it opens another form which has a reportviewer control, this reportviewer is bind to a report, but that report takes some seconds to load the parametes and it locks both forms, is possible to open it while its still loading the report viewer
How can I achieve this with c#
the only code I have in the app is this
private void reporte1ToolStripMenuItem_Click(object sender, EventArgs e){
FrmOcupacionDisco frmOc = new FrmOcupacionDisco();frmOc.Show();
}

Open form asynchronosly with reportviewer?
RHolt
Hey tio!
You can make this by using a Multi-Threading way, Here are a simple example:
ThreadPool
.QueueUserWorkItem(delegate{
MyForm mform =
new MyForm();mform.Show();
});
Learn more about MultiThreading at: https://msdn2.microsoft.com/en-us/library/hyz69czz.aspx
niallhannon
Try using this code:< xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />
private void reporte1ToolStripMenuItem_Click(object sender, EventArgs e)
{
ThreadPool.QueueUserWorkItem(delegate
{
// Creates the slow-to-load form..
FrmOcupacionDisco TempFrm = new FrmOcupacionDisco();
if (InvokeRequired)
{
// Invokes a Event to pass the new form
// to the another Thread to be handled locally.
Invoke(new WaitCallback(FormCreationCompleted), TempFrm);
}
});
}
// When the another thread is completed then you can set the properties
// or to execute the methods of the form. But you need to pass it from
// the another Thread.
void FormCreationCompleted(object o)
{
if (o != null && o is FrmOcupacionDisco)
{
// Set Properties Here!
FrmOcupacionDisco frmOc = (o as FrmOcupacionDisco);
frmOc.MdiParent = this;
frmOc.ShowDialog();
}
}
Regards
Mats S&#246;derlund
DocSteve
All the following changes should be made in MDI child form. Try these steps:
1. Unbind the report from the viewer.
2. Add a backgroundworker to the form.
3. In the form's Load eventhandler, call the backgroundworker's RunWorkerAsync method.
4. In the backgroundworker's DoWork eventhandler, load the report and set the parameter values.
5. In the backgroundworker's RunWorkerCompleted eventhandler, bind the report to the viewer.
That should do it.
Tony
Roxanne163
Cross-thread operation not valid: Control 'Form1' accessed from a thread other than the thread it was created on.
private void reporte1ToolStripMenuItem_Click(object sender, EventArgs e){
ThreadPool.QueueUserWorkItem(delegate{
FrmOcupacionDisco frmOc = new FrmOcupacionDisco();frmOc.MdiParent =
this;frmOc.Show();
});
//FrmOcupacionDisco frmOc = new FrmOcupacionDisco(); //frmOc.MdiParent = this; //frmOc.Show();}