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.