Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
675
Cross-thread operation not valid error on Form.Dispose(disposing) function
posted

Hi, Guys

I'm running into this Cross-thread exception when we dispose one of our forms. Eventually I tracked it down to an UltraLabel contained in the form. The difference between this UltraLabel and other child controls, is that this control is not created inside the InitializeComponent() function, but was created after InitializeComponent() was called. Once I moved the creation of the UltraLabel into InitializeComponent(), the problem goes away. Can you shed some light on what magic goes on inside InitializeComponent() that cures this issue? Was there a different thread invoked in it to create controls? 

Thanks.

  • 23930
    Offline posted

    Hi,

    I am just checking about the progress of this issue. Let me know if you need my further assistance on this issue.

    Thank you for using Infragistics Components.

  • 23930
    Offline posted

    Hi,

    Thank you for posting in our forums.

    The InitializeComponent method is responsible for implementing all the settings you have set through the designer of the form and is generated by the designer itself. Other than that there isn’t anything else that special about this method.

    It’s hard for me to give you the exact reason why the issue was happening without any sample, but the cross-thread exceptions happen when you access the form or a control from a different thread, than the one it was created on. How were you creating the UltraLabel before? The InitializeComponent method is executed from the UI Thread, so that is probably the reason why the issue is not present anymore. If you are able to provide me with a sample that reproduces the issue I would be glad to research this further for you.

    Please let me know if you have any additional questions.