473,395 Members | 1,577 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

processor time

Hi,
I have a calculation program in vb.net who is running for let us say for
more than a hour.
When I will do meanwhile something els in a office program I see that my
calculation program takes a great part (maybe 80% or more) of the processor
time and I want that it is for both 50% when the office program is using
the processor.
Is this normal and can I do somthing in the code of my calculation program
or is this simple impossible.
Thanks for any response.
Sep 4 '06 #1
8 2307
I have a calculation program in vb.net who is running for let us say for
more than a hour.
When I will do meanwhile something els in a office program I see that my
calculation program takes a great part (maybe 80% or more) of the processor
time and I want that it is for both 50% when the office program is using
the processor.
Is this normal and can I do somthing in the code of my calculation program
or is this simple impossible.
Thanks for any response.
For the thread(s) that do the calculating, set
thread.Priority = Threading.ThreadPriority.BelowNormal
Your calculation will relinquish the cpu to other processes (eg office) and
their threads whenever the others make cpu demands. When other processes are
idle, your calculation will use 100% cpu.
Sep 4 '06 #2
thanks!

"AMercer" <AM*****@discussions.microsoft.comschreef in bericht
news:5F**********************************@microsof t.com...
>I have a calculation program in vb.net who is running for let us say for
more than a hour.
When I will do meanwhile something els in a office program I see that my
calculation program takes a great part (maybe 80% or more) of the
processor
time and I want that it is for both 50% when the office program is
using
the processor.
Is this normal and can I do somthing in the code of my calculation
program
or is this simple impossible.
Thanks for any response.

For the thread(s) that do the calculating, set
thread.Priority = Threading.ThreadPriority.BelowNormal
Your calculation will relinquish the cpu to other processes (eg office)
and
their threads whenever the others make cpu demands. When other processes
are
idle, your calculation will use 100% cpu.

Sep 4 '06 #3
Hello AMercer,

Adjusting thread priorities is NOT a good idea if you can avoid it. I'm
thinking about Office and I can't conceive of a sinple application in that
suite that would require 50% of the processor. Word sits idle most of the
time.. so does Excel.. Outlook may consume a tiny bit more but for the most
part it too is idle..

-Boo
>I have a calculation program in vb.net who is running for let us say
for
more than a hour.
When I will do meanwhile something els in a office program I see that
my
calculation program takes a great part (maybe 80% or more) of the
processor
time and I want that it is for both 50% when the office program is
using
the processor.
Is this normal and can I do somthing in the code of my calculation
program
or is this simple impossible.
Thanks for any response.
For the thread(s) that do the calculating, set
thread.Priority = Threading.ThreadPriority.BelowNormal
Your calculation will relinquish the cpu to other processes (eg
office) and
their threads whenever the others make cpu demands. When other
processes are idle, your calculation will use 100% cpu.

Sep 4 '06 #4
Adjusting thread priorities is NOT a good idea if you can avoid it. I'm
thinking about Office and I can't conceive of a sinple application in that
suite that would require 50% of the processor. Word sits idle most of the
time.. so does Excel.. Outlook may consume a tiny bit more but for the most
part it too is idle..
If one wants decent response from another app, office or otherwise, lowering
the priority of a cpu bound worker is just about perfect. In every version
of windows that I have used, a cpu bound thread adversely affects the
responsiveness of other interactive apps.

Sep 4 '06 #5
I have set the following commands in my program and it started obviously
well :

Dim tr As New Thread(AddressOf HaalUitverkorenen)

tr.Priority = Threading.ThreadPriority.BelowNormal

tr.Start()

HaalUitverkorenen()

If tr.ThreadState = Threading.ThreadState.Running Then

tr.Abort()

End If
But I recieved quickly a exception because I put a string in a textbox
during the excecution of the sub HaalUitverkorenen :
the exception was telling :

Cross-thread operation not valid: Control 'TextBox1' accessed from a thread
other than the thread it was created on.

the textbox was placed in the beginning of the design on my form

what can I do?


"AMercer" <AM*****@discussions.microsoft.comschreef in bericht
news:5F**********************************@microsof t.com...
>I have a calculation program in vb.net who is running for let us say for
more than a hour.
When I will do meanwhile something els in a office program I see that my
calculation program takes a great part (maybe 80% or more) of the
processor
time and I want that it is for both 50% when the office program is
using
the processor.
Is this normal and can I do somthing in the code of my calculation
program
or is this simple impossible.
Thanks for any response.

For the thread(s) that do the calculating, set
thread.Priority = Threading.ThreadPriority.BelowNormal
Your calculation will relinquish the cpu to other processes (eg office)
and
their threads whenever the others make cpu demands. When other processes
are
idle, your calculation will use 100% cpu.

Sep 5 '06 #6
I have set the following commands in my program and it started obviously
well :

Dim tr As New Thread(AddressOf HaalUitverkorenen)
tr.Priority = Threading.ThreadPriority.BelowNormal
tr.Start()
HaalUitverkorenen()
If tr.ThreadState = Threading.ThreadState.Running Then
tr.Abort()
End If

But I recieved quickly a exception because I put a string in a textbox
during the excecution of the sub HaalUitverkorenen :
the exception was telling :

Cross-thread operation not valid: Control 'TextBox1' accessed from a thread
other than the thread it was created on.

the textbox was placed in the beginning of the design on my form

what can I do?
I see two things that look like problems. First, you do tr.Start() on a
thread that will run at function HaalUitverkorenen(), and then your main
thread also calls functionHaalUitverkorenen(). This looks to me like you
will execute HaalUitverkorenen() twice, once on the new thread and once on
the main thread. In the code fragment, I think all you need is
Dim tr As New Thread(AddressOf HaalUitverkorenen)
tr.Priority = Threading.ThreadPriority.BelowNormal
tr.Start()

Second, there is a issue with windows where code that operates on some
controls has to execute on the same thread that the control execute on. So,
once you run HaalUitverkorenen() on its own thread, it cannot manipulate
forms and controls directly. There is a variety of written material on how
to solve this problem in the .net help documentation under the topic of
Invoke. The general idea is that your HaalUitverkorenen() thread can be made
to execute gui code on the gui main thread by appropriate function calls.
Sep 6 '06 #7
Yes, I had seen the first problem and the second I will try your
propositiion.
But should it be not better to give the whole program at once a lower
priority so tha it runs for 100% if there are no other programs and for
let's say 10% if other programs have to use the processor.
I don't know if this is possible and if it is, what is the solution
(commands) for this?
Thanks for any response
"AMercer" <AM*****@discussions.microsoft.comschreef in bericht
news:71**********************************@microsof t.com...
>I have set the following commands in my program and it started obviously
well :

Dim tr As New Thread(AddressOf HaalUitverkorenen)
tr.Priority = Threading.ThreadPriority.BelowNormal
tr.Start()
HaalUitverkorenen()
If tr.ThreadState = Threading.ThreadState.Running Then
tr.Abort()
End If

But I recieved quickly a exception because I put a string in a textbox
during the excecution of the sub HaalUitverkorenen :
the exception was telling :

Cross-thread operation not valid: Control 'TextBox1' accessed from a
thread
other than the thread it was created on.

the textbox was placed in the beginning of the design on my form

what can I do?

I see two things that look like problems. First, you do tr.Start() on a
thread that will run at function HaalUitverkorenen(), and then your main
thread also calls functionHaalUitverkorenen(). This looks to me like you
will execute HaalUitverkorenen() twice, once on the new thread and once on
the main thread. In the code fragment, I think all you need is
Dim tr As New Thread(AddressOf HaalUitverkorenen)
tr.Priority = Threading.ThreadPriority.BelowNormal
tr.Start()

Second, there is a issue with windows where code that operates on some
controls has to execute on the same thread that the control execute on.
So,
once you run HaalUitverkorenen() on its own thread, it cannot manipulate
forms and controls directly. There is a variety of written material on
how
to solve this problem in the .net help documentation under the topic of
Invoke. The general idea is that your HaalUitverkorenen() thread can be
made
to execute gui code on the gui main thread by appropriate function calls.

Sep 7 '06 #8
But should it be not better to give the whole program at once a lower
priority so tha it runs for 100% if there are no other programs and for
let's say 10% if other programs have to use the processor.
I don't know if this is possible and if it is, what is the solution
(commands) for this?
There is no way to guarantee 10% (or about 10%) cpu demand. Ready to run
threads at higher priority win over threads at lower prioirty, and threads of
equal priority share cpu equally. That is not a complete description of what
windows does, but it is the way you should view it.

I think it is better for the gui thread of your program to run at ordinary
priority and the cpu bound calculation thread to run at BelowNormal priority.
In this way, the calculation thread will use whatever cpu is available, and
your app's gui will be just as responsive as any other app.

Sep 7 '06 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Amit Dedhia | last post by:
Hi I am developing a Dot net application (involving image processing) on a uni processor. It works well on my machine. I then take all my code on a multi processor, build and run the application...
5
by: Jorch | last post by:
Hi, Can you help me?? Why code 1 eats up 100% of processor time when browser window is active and code 2 doesn't???? Do I use setTimeout wrong somehow??? Code 1 changes visibility of div...
1
by: Jeff Mitchell | last post by:
I have a logging application that records various performance metrics into a database every 5 minutes, and to this I'd like to add a performace counter that shows the processor usage in a manner akin...
0
by: dtp | last post by:
This one has got me stumped. Is there a way to figure out the utilization of each processor in an MP system? (2P and above) Right now I use the NtQuerySystemInformation API to get busy and idle...
4
by: kaiteriteri | last post by:
I have a time-consuming VB.net application that i'd like to thread over 2 processors (that's all i've got in my machine!) and, hopefully, get it done in half the time. On running, the application...
3
by: Michel Meex | last post by:
Hello, I have an application, that has been running on a single processor server for more then a year without any problems. Now I'm migrating to a dual processor server, and I'm experiencing...
1
by: Henrik | last post by:
I have a problem with processor load in the enviroment where I'm running the firts installation of my new application. My program is running on a Pentium 4 3.0 GHz, wtih 1 GB DDR SDRAM and 80 GB...
168
by: broeisi | last post by:
Hello, Is there a way in C to get information at runtime if a processor is 32 or 64 bit? Cheers, Broeisi
6
by: Peter Graf | last post by:
Hi, I want to use to quadcore processor to calculate a matrix with a C++-program. The elapsed time for calculating one entry is very variably (approx. 1-30 min) and I'm not able to estimate the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.