WinForms form freezes
- by andrew
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();
}
}