.NET Threading problem

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi all

I'm developing multi-threading program

I have 4 threads running in my program and every thread work busy. I see some thread (from IDE debugger) pause about 5 seconds or more but I don't know why. So this is seriously problem for me because I need my program work smooothly

Is there someone ever found this problem

Is there someone can introduce me best practice for threading program and shared resource

Thanks
KPH
 
I have seen situations where multithreaded applications behave strangely
when run from the debugger.

Try to run you program without debugging and see if you get the same
problem.

Pete

KPH said:
Hi all,

I'm developing multi-threading program.

I have 4 threads running in my program and every thread work busy. I see
some thread (from IDE debugger) pause about 5 seconds or more but I don't
know why. So this is seriously problem for me because I need my program work
smooothly.
 
Hello,

Thanks for your post. I agree with Pete that you can check if it works
properly without the debugger.

In addition, do you use some synchronization objects say, mutex, which
protect share the resources? If so, does the thread pause at waiting the
synchronization signal?

I also believe the following MSDN article are helpful:

Threads and Threading
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/htm
l/cpconthreadsthreading.asp

Synchronizing Data for Multithreading
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/htm
l/cpconmanagedthreadingsupport.asp

Have a nice day!

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
This is just a random possibility, but by any chance are you calling an
Invoke() method from a windows forms control, i.e.
ListView.Invoke(somedelegate) ?

If you're in a function on the main UI thread, and you spawn a separate
thread which tries to do a Control.Invoke(), I've found that the Invocation
will wait until the main UI thread is available in order to run on that
thread. Doing this can cause your thread to hang if the main UI thread
doesn't become available for awhile.

KPH said:
Hi all,

I'm developing multi-threading program.

I have 4 threads running in my program and every thread work busy. I see
some thread (from IDE debugger) pause about 5 seconds or more but I don't
know why. So this is seriously problem for me because I need my program work
smooothly.
 
..NET threads are agile. They can be interrupted, put to sleep, suspended at
the discretion of the operating system at ANY time. You should write
applications based on thread agility and not the other way around.
 
Back
Top