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 1090657
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T23:24:25+00:00 2026-05-16T23:24:25+00:00

I am using Visual C# .Net via Visual Studio 2008 Express and I am

  • 0

I am using Visual C# .Net via Visual Studio 2008 Express and I am launching a thread from a forms applications to wait on incoming data in a loop. So, each loop waits till data is available, then gets the data, and starts again waiting.

The main reason why I’m waiting for my data in a separate thread is so my form will still allow interaction while the other sits there waiting for data.

For whatever reason, my form will lock while my other thread is waiting.

Unfortunately, I am forced to use a proprietary function to acquire my data. Processing will literally stop at that function till data is returned by it (which waits on hardware inputs). So, a user can click in vain on menu options with no effect, till the child thread returns data and all the clicked menu options will quickly change status and lock up again.

So, my question is:
Why is my child thread holding up my form? Isn’t is supposed to be independent?
What can I do to force my form to continue to function if that child thread is waiting on something?

I am currently making my thread like this:

ControlThread = new Thread(new ThreadStart(Run));
ControlThread.Start();

Where my Run function is something like this:

public void Run()
{
    while (!StopEventHandle.WaitOne(0, true))
    {
        int data = WaitForData();
        invoke(DelegatedResults);
    }
}

Where DelegatedResults is a function on my form that updates some textboxes using the data that came in.

  • 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-16T23:24:25+00:00Added an answer on May 16, 2026 at 11:24 pm

    I am forced to use a proprietary function to acquire my data

    You didn’t say much about that function. Your problem suggests that it was implemented as a COM server, pretty common. COM takes care of the threading requirements for the COM server. Such a server indicates in the registry with the ThreadingModel registry key what kind of threading it supports. A very common setting is “Apartment”, also the default when the key is missing.

    That setting indicates that the server doesn’t support threading. It needs a Single Threaded Apartment (STA). COM takes care of that and it automatically marshals any call made on the server to an STA thread. Your UI thread. Which thus goes dead as a doornail until the call completes.

    There ought to be something about this in the documentation for the library. Contacting the vendor for support would be a good idea as well. If you can’t get help then the first thing you could try is initializing the server on the worker thread instead of your UI thread. That would solve the problem if the ThreadModel is “Both”. If that doesn’t help then you’ll need to create your own STA thread. Call Thread.SetApartmentState() before starting the thread, start your own message loop with Application.Run() in the thread. You might be able to skip the loop but it is normally required.

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

Sidebar

Related Questions

Using Visual Studio 2008, c#, .net 2.0. I have a Windows Forms client application
I'm converting a VB6 dll to VB.Net using Visual Studio 2008 Express. I want
We have a project written in VB.NET using Visual Studio 2008 that is to
I am making a Multilingual Website with ASP.NET using visual studio 2008. In my
I've developed a Notepad kinda Windows application in VB.NET using Visual Studio 2008. Is
We develop asp.net webforms using visual studio 2008. For multilingual support, we translate all
I am using ASP.NET MVC 2 & .Net 3.5 with Visual Studio 2008. Ok,
I am currently using Visual Studio 2008 for my ASP .NET application. I am
I am new to the .NET Framework. I am using Visual Studio 2008 in
I'm developing an ASP.NET 2.0 app using Visual Studio 2008. If I want to

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.