Link to home
Start Free TrialLog in
Avatar of korpiklaani
korpiklaani

asked on

Multithreading causes slow down

My application is multithreaded, at most cases it runs up to 3 extra threads at the same time.
Some of my software users have issues with getting their pc slowed down alot.
They said the application is using up to 100% system usage, i cant find howto solve this problem by myself.
The first thread which is taking alot usage is doing the following:
calls to System.Diagnostics.Process.GetProcessesByName() to check if a specific process is running and several ReadProcessMemory calls.
I already tried Thread.Priority = lowest but it doesnt helps at all.
Avatar of Jens Fiederer
Jens Fiederer
Flag of United States of America image

How often do you do System.Diagnostics.Process.GetProcessesByName()?  

Just once, or continuously?  If continuously, you might want to sleep a bit between calls.
Avatar of korpiklaani
korpiklaani

ASKER

i have a 500ms sleep at the end of the thread
And the thread does not contain a loop?
the thread loops using a while loop
Have you tried putting your "sleep" INSIDE the while loop?
yes of course, it is inside the while loop
OK, you said at the "end of the thread".

Are there any other loops in the thread that could be busy-waiting?
no other loops, i found when i put the sleep at the end on 5000ms it works way better but is that the only solution?
500ms sleeps should be enough to avoid 100% usage...how about the other threads?

they are not running at that time, later they just get started.
well but even 50% is too much with 500ms
How much does it go to with 5000ms?
0 - 1%
ASKER CERTIFIED SOLUTION
Avatar of Jens Fiederer
Jens Fiederer
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
i guess that is the only way