My Winforms app needs to launch one or more non-modal Report Viewer windows, after which the main window goes about its business(which includes opening modal dialogs). I found the code below (by H. Passant) in an earlier article:
private void button1_Click(object sender, EventArgs e) {
var t = new System.Threading.Thread(() => Application.Run(new Form2()));
t.SetApartmentState(System.Threading.ApartmentState.STA);
t.Start();
}
In my case, "Form2" contains a single docked ReportViewer control set up to display the desired report [new frmRptView(sReport, aRptParams)].
All seemed to work well during my testing, but when I gave a build to testers, they reported the viewer windows would sometimes lock up, and the only way to get rid of them was to log out or reboot. We had the same trouble using form.Show(), too.
edit: What is the correct way to launch a non-modal window so it will be independent of the main app window?