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 .GetProces sesByName( ) to check if a specific process is running and several ReadProcessMemory calls.
I already tried Thread.Priority = lowest but it doesnt helps at all.
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
I already tried Thread.Priority = lowest but it doesnt helps at all.
ASKER
i have a 500ms sleep at the end of the thread
And the thread does not contain a loop?
ASKER
the thread loops using a while loop
Have you tried putting your "sleep" INSIDE the while loop?
ASKER
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?
Are there any other loops in the thread that could be busy-waiting?
ASKER
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?
ASKER
they are not running at that time, later they just get started.
well but even 50% is too much with 500ms
well but even 50% is too much with 500ms
How much does it go to with 5000ms?
ASKER
0 - 1%
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
i guess that is the only way
Just once, or continuously? If continuously, you might want to sleep a bit between calls.