Another option is to place a backgroundworker on the form. Then in the events, doubleclik on 'DoWork' in the method that is then created in code, place the messagebox.show. This way the messagebox is shown in a separate thread and the loading of the form will continue
Confusing in event Form_Load
Domanda
private void Form1_Load(object sender, EventArgs e)
{
MessageBox.Show("Luanching.... This may take a few second");
............
}
Here if I don't click OK in messagebox my from will not show up (It will wait until me click) how to fix this how to make form show up first or how to make doesn't wait for click OK
Soluzione
Altri suggerimenti
Simple, Just move the MessageBox code to Shown
event
private void Form1_Shown(object sender, EventArgs e)
{
MessageBox.Show("Luanching.... This may take a few second");
}
You don't need to use MessageBox
, you have to create a new Form
which shows a message.
New Form
will run on a new message loop, so will not block ui, if call it like
myForm.Show()
, where myForm
is your form's instance.
The event Form1_Load
is exaclty what it sounds, so if you insert some sort of MessageBox
there, the Form
will only load after the response.
Consider using another method, after the Form
load.
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow