Hi,
I am having a thread hang problem in my c# code.
The example on the website: http://csharp.web1000.com/ is a
simplified version of my problem.
You will see in the form that a method TestThread increments a number in the
textbox on the form.
TestThread is called from a worker thread (2nd thread) using a TimerThread.
Every 2 seconds it will increment the number in te text box.
First start the project from the form (form1 class is the startup object).
The Form is displayed. Now push the button, this will create the
TimerThread.
You now see nicely that the number increments every 2 seconds.
Now start the application from the class (class1 is the startup object).
Now the TimerThread will be created in the Class1 object.
You will see that the number is never incremented.
When stepping through the code you will see that the TestThread method is
called.
The TestThread code in the form properly detects that this is run from a
second thread (line InvokeRequired) and continues to the line where Invoke
is called. I use Invole so that the increment function would run on the
forms thread. It is here where the application seems to hang. The number in
the textbox is never incremented.
Can anyone explain me why this is happening or how to solve this ?
i was wondering, might this have something to do with Apparementthreading ?
(this is used when you start the application from the form (=startup
object)).
Maybe when you start it from the class this is no longer the case ?
Maybe it's something completely different.
Thanks for shedding some light in the darkness.
Regards, Serge
http://csharp.web1000.com/