WinForms form freezes

Posted by andrew on Stack Overflow See other posts from Stack Overflow or by andrew
Published on 2010-05-19T08:10:53Z Indexed on 2010/05/19 8:20 UTC
Read the original article Hit count: 379

Filed under:
|
|

On a form (F1) i have a button, from which if i create another form (lets call it F2) and show it there's no problem

but i'd like to do something like this

Some thread in my app is running a connection and listens for messages from a server. when a message arrives, my main form is registered to get an event that runs a function. From that function i'm trying to create and show the F2 type form (empty, nothing modified in it): it shows it but then it freezes my application.

more exactly:

public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();
        ConnectionManagerThread.getResponseListener().MessageReceived += Form1_OnMessageReceived;
    }

    private void Form1_OnMessageReceived(object sender, MessageEventArgs e) {
        Form2 f2 = new Form2();
        f2.Show();
    }
}

© Stack Overflow or respective owner

Related posts about c#

Related posts about .NET