No. You must create the form on the UI thread. Likewise, you can only
access it from the UI thread. That is mandatory.
The following code snippet should help explain how this might be done.
I've omitted some stuff brevity, but I think you'll get the idea.
// .NET 1.1
public class YourBackgroundW orkerClass
{
// Get a reference to one of your app's forms here.
private Form mainForm;
private void YourBackgroundT hreadMethod()
{
// Do some stuff.
DisplayYourDial ogForm();
// Do some more stuff.
}
private void DisplayYourDial ogForm()
{
if (mainForm.Invok eRequired)
{
Delegate method = new ThreadStart(thi s.DisplayYourDi alogForm);
mainForm.Invoke (method, null);
}
else
{
YourDialogForm form = new YourDialogForm( );
form.ShowDialog ();
}
}
}
// .NET 2.0
public class YourBackgroundW orkerClass
{
// Get a reference to one of your app's forms here.
private Form mainForm;
private void YourBackgroundT hreadMethod()
{
// Do some stuff.
ThreadStart method = delegate()
{
YourDialogForm form = new YourDialogForm( );
form.ShowDialog ();
};
mainForm.Invoke (method, null);
// Do some more stuff.
}
}
Todd wrote:
Any way to tell the dialog created in the background thread to use the
foreground app's thread???
"Brian Gideon" wrote: