Daaksin
Daaksin

Reputation: 894

WinForm hangs when opened

I'm trying to start a new WinForm up when a particular message is received over network, I am absolutely sure that the message is being received, because the form opens. However, when it does, it hangs and doesn't stop. I suspect this is because I'm opening it from a thread other than the UI thread, but have no idea how to fix it. I have tried this:

private delegate void OpenFormDV();
    public void OpenForm()
    {
        if (this.InvokeRequired) { OpenFormDV openForm = new OpenFormDV(OpenForm); }
        else {
            NewForm newForm = new NewForm();
            newForm.Show();
        }
    }

But the form still freezes. How can I fix it?

Upvotes: 0

Views: 169

Answers (1)

Sayris
Sayris

Reputation: 1070

May be the answer of this question is in this thread:

C# calling form.show() from another thread

You must use a global Invoke to interact with your newForm.

Upvotes: 3

Related Questions