How to invoke a method using the thread which created the object

Discussion in 'ASP .Net' started by Henrik Dahl, May 21, 2004.

  1. Henrik Dahl

    Henrik Dahl Guest

    Hello!

    In my program I've made an STA thread which is running separately from the
    main thread. The STA thread is instantiating some COM objects. Is it
    possible, from the main thread, to invoke the COM object using the thread
    which instantiated it? This situation compares quite much to the Invoke
    method of the Windows Forms Control class. Do some of you know how to
    achieve that?


    Best regards,

    Henrik Dahl
     
    Henrik Dahl, May 21, 2004
    #1
    1. Advertisements

  2. Henrik,
    I guess the easiest way would be to create a hidden window on the STA
    thread, then use Control.Invoke() on that window from the main thread
    to make sure whatever method you want to call runs on the STA thread.



    Mattias
     
    Mattias Sjögren, May 21, 2004
    #2
    1. Advertisements

  3. Henrik Dahl

    Henrik Dahl Guest

    Mattias,

    As usual, thank you very much.


    Best regards,

    Henrik Dahl
     
    Henrik Dahl, May 21, 2004
    #3
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.