How do I pass a reference type to Control.Invoke / display a form centered on the main form
        Posted  
        
            by Rubio
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Rubio
        
        
        
        Published on 2010-06-03T07:52:15Z
        Indexed on 
            2010/06/03
            8:04 UTC
        
        
        Read the original article
        Hit count: 377
        
I'm on a thread other than the UI thread and need to display a modal form that's centered on the application's main form. What I usually do is use the width and height of the main form and the modal form to calculate the location, then use the PointToScreen method of the main form to get the location of the modal form. Since I'm on another thread I need to use Control.Invoke to call this method. I just can't figure out how to pass a parameter of type Point to Control.Invoke (params object[]). Value types and String works fine.
Or, if someone can find a better way to display a form centered on the main form regardless of thread, that would be great. MessageBox seems to be able to do this (although not modally).
© Stack Overflow or respective owner