Closing form error with Invoke RRS feed

  • Question

  • I'm using separate thread to delay certain functions but if I close the form on purpose when it's running I get invoke errors in the debugger. If I run from .exe it causes Windows to tell me the program basically crashed. I could circumvent it all with a bunch of try/catch blocks, but that's not good coding practice.


    Any ideas how to get around this stuff? The Invoke is accessing controls which don't exist when the form is closing, thus the error. I tried aborting the thread in the closing events but apparently it's null by then. I'm new to threading so I'm kinda stuck.


    Error: "Invoke or BeginInvoke cannot be called on a control until the window handle has been created."

    Saturday, April 14, 2007 10:25 PM