Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6742911
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T11:53:56+00:00 2026-05-26T11:53:56+00:00

I am using a COM component which is absurdly slow (takes few minutes to

  • 0

I am using a COM component which is absurdly slow (takes few minutes to give me requested data) so to keep the UI responsive, in my WPF application, I am thinking of using either Task or BackgroundWorker Classes to create a background thread, and disable all controls on UI to prevent any problems, as the component is not threadable.

The component is added to the project simply as a standard COM reference. The problem is that it simply doesn’t work (including initialization using new) from any background thread. It works fine from the UI thread. Any pointers will be appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T11:53:57+00:00Added an answer on May 26, 2026 at 11:53 am

    Did you try to add [STAThread] attribute to Main()?

    [STAThread]
    static void Main()
    {
    }
    

    When the STAThreadAttribute is applied, it changes the apartment state of the current thread to be single threaded.
    Without getting into a huge discussion about COM and threading, this attribute ensures the communication mechanism between the current thread and other threads that may want to talk to it via COM.
    This attribute is usually automatically applied to Main when you start a new UI project.


    Or (as SLaks told me) you can try:

    Thread t = new Thread(ThreadProc);
    t.SetApartmentState(ApartmentState.STA);
    ....
    
    public void ThreadProc()
    {
        // Thread function
    }
    

    You could also want to use

    bool result = t.TrySetApartmentState(ApartmentState.STA);
    

    and check result value to be sure that your try was succesful

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have developed a C# com component which I am using from managed c++.
I have an eclipse plugin, which connects to a COM component using Jacob. But
I created a com component in C#, which I registered by using Regasm. I
I have a VBScript COM Component where I'm using Msxml2.FreeThreadedDOMDocument.4.0 however is there /
Is is possible to create COM component and ActiveX controls in .Net (using c#
When using COM boolean values are to be passed as VARIANT_BOOL which is declared
I've written a .NET DLL which is called from another application using COM interop.
I have a .net application calling to a COM component (C++) which in turn
I have a wrapper managed application(.net) over a COM Component(created using vb6) where Com
My Bank has givien me the option of using a COM component, Java (JAR)

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.