processor time

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • andreas

    #1

    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.


  • AMercer

    #2
    RE: processor time

    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.Threa dPriority.Below Normal
    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.

    Comment

    • andreas

      #3
      Re: processor time

      thanks!

      "AMercer" <AMercer@discus sions.microsoft .comschreef in bericht
      news:5FA869AE-6E4A-4ECB-B062-49F03D224146@mi crosoft.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.Threa dPriority.Below Normal
      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.

      Comment

      • GhostInAK

        #4
        RE: processor time

        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.Threa dPriority.Below Normal
        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.
        >

        Comment

        • AMercer

          #5
          RE: processor time

          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.

          Comment

          • andreas

            #6
            Re: processor time

            I have set the following commands in my program and it started obviously
            well :

            Dim tr As New Thread(AddressO f HaalUitverkoren en)

            tr.Priority = Threading.Threa dPriority.Below Normal

            tr.Start()

            HaalUitverkoren en()

            If tr.ThreadState = Threading.Threa dState.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 HaalUitverkoren en :
            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" <AMercer@discus sions.microsoft .comschreef in bericht
            news:5FA869AE-6E4A-4ECB-B062-49F03D224146@mi crosoft.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.Threa dPriority.Below Normal
            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.

            Comment

            • AMercer

              #7
              Re: processor time

              I have set the following commands in my program and it started obviously
              well :
              >
              Dim tr As New Thread(AddressO f HaalUitverkoren en)
              tr.Priority = Threading.Threa dPriority.Below Normal
              tr.Start()
              HaalUitverkoren en()
              If tr.ThreadState = Threading.Threa dState.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 HaalUitverkoren en :
              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 HaalUitverkoren en(), and then your main
              thread also calls functionHaalUit verkorenen(). This looks to me like you
              will execute HaalUitverkoren en() 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(AddressO f HaalUitverkoren en)
              tr.Priority = Threading.Threa dPriority.Below Normal
              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 HaalUitverkoren en() 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 HaalUitverkoren en() thread can be made
              to execute gui code on the gui main thread by appropriate function calls.

              Comment

              • andreas

                #8
                Re: processor time

                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" <AMercer@discus sions.microsoft .comschreef in bericht
                news:71AB14B1-4A51-40D6-A638-2F578EBE8EBD@mi crosoft.com...
                >I have set the following commands in my program and it started obviously
                >well :
                >>
                >Dim tr As New Thread(AddressO f HaalUitverkoren en)
                >tr.Priority = Threading.Threa dPriority.Below Normal
                >tr.Start()
                >HaalUitverkore nen()
                >If tr.ThreadState = Threading.Threa dState.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 HaalUitverkoren en :
                >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 HaalUitverkoren en(), and then your main
                thread also calls functionHaalUit verkorenen(). This looks to me like you
                will execute HaalUitverkoren en() 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(AddressO f HaalUitverkoren en)
                tr.Priority = Threading.Threa dPriority.Below Normal
                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 HaalUitverkoren en() 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 HaalUitverkoren en() thread can be
                made
                to execute gui code on the gui main thread by appropriate function calls.

                Comment

                • AMercer

                  #9
                  Re: processor time

                  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.

                  Comment

                  Working...