• Welcome to Valhalla Legends Archive.
 

C# Invoking a Form?

Started by Chriso, October 19, 2007, 03:45 AM

Previous topic - Next topic

Chriso

I am having some problems trying to show a form from another thread, the form gets shown but is in a frozen (non-responsive) state.

Heres the code...

frmProfile p = new frmProfile();
p.Show();


Any ideas?

MyndFyre

I typically use this delegate for my invocations:

private delegate void SyncDel();


Do you have an instance of your main form?

SyncDel del = delegate()
{
    frmProfile p = new frmProfile();
    p.Show();
};
if (mainForm.InvokeRequired)
    mainForm.Invoke(del);
else
    del();


This should work on any pre-existing control.  You just need a control that's already there.  I'm guessing that you're inside of an event handler - your sender parameter should even work, cast to Control. :)
QuoteEvery generation of humans believed it had all the answers it needed, except for a few mysteries they assumed would be solved at any moment. And they all believed their ancestors were simplistic and deluded. What are the odds that you are the first generation of humans who will understand reality?

After 3 years, it's on the horizon.  The new JinxBot, and BN#, the managed Battle.net Client library.

Quote from: chyea on January 16, 2009, 05:05 PM
You've just located global warming.

Chriso

Thanks a lot mate, its work now :)