문제

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

도움이 되었습니까?

해결책

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

다른 팁

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top