views:

109

answers:

2

Hi,

I'm getting this error: Invoke or BeginInvoke cannot be called on a control until the window handle has been created.

On these lines:

        m_SplashForm.Invoke(
                new SplashStatusChangedHandle(delegate(string str) { m_SplashInterface.SetStatusInfo(str); }),
                new object[] { value }
            );

I'm trying to use Application.Exit()

Can anyone help me?

Thanks in advance

A: 

Hook to the Control.OnHandleCreated event then you will be permited to do Application.Exit().

Cedrik
+1  A: 

The error message pretty much says it all here. Invoke and BeginInvoke cannot be used on a control until the underlying handle is created. This typically happens when the Form is initially displayed. Are you not displaying the form?

You can also force the issue by calling the CreateControl method.

JaredPar
Careful with that CreateControl comment. The failure you'd get by calling it from the thread will be *very* hard to diagnose.
Hans Passant