Valhalla Legends Forums Archive | .NET Platform | C# Invoking a Form?

AuthorMessageTime
DDA-TriCk-E
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...
[code]
frmProfile p = new frmProfile();
p.Show();
[/code]

Any ideas?
October 19, 2007, 8:45 AM
Myndfyr
I typically use this delegate for my invocations:
[code]
private delegate void SyncDel();
[/code]

Do you have an instance of your main form?
[code]
SyncDel del = delegate()
{
    frmProfile p = new frmProfile();
    p.Show();
};
if (mainForm.InvokeRequired)
    mainForm.Invoke(del);
else
    del();
[/code]

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. :)
October 19, 2007, 9:04 AM
DDA-TriCk-E
Thanks a lot mate, its work now :)
October 19, 2007, 9:36 AM

Search