Unexpected cross threading issue
        Posted  
        
            by 
                haughtonomous
            
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by haughtonomous
        
        
        
        Published on 2012-12-10T16:57:09Z
        Indexed on 
            2012/12/10
            17:03 UTC
        
        
        Read the original article
        Hit count: 279
        
I'm trying to do something very simple in principal, but I keep getting a cross-threading exception which has me stumped because I'm not setting out to use multiple threads.
I have a Windows Forms application. It launches another Windows Forms application (using the System.Diagnostics.Process class) , and catches the Exited event when that application is closed. My application event handler then tries to copy text from the clipboard to a control on the current displayed form. At this point a Cross-threading exception is thrown.
I assume that the problem is that the event from the closing application is in another thread (I'm outside my comfort zone here, so bear with me), so the question boils down to "How do I prevent this exception?"
I'm somewhat constrained into having to copy from the clipboard, but I could launch the other application a different way if that would solve the problem.
© Stack Overflow or respective owner