Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. does MethodInvoker will not work on win XP?

does MethodInvoker will not work on win XP?

Scheduled Pinned Locked Moved C#
performancequestion
5 Posts 3 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    Gilbert Consellado
    wrote on last edited by
    #1

    I have a method something like this.

    private void PrintSomething()
    {
    //some code here
    }

    then calling this method like this

    MethodInvoker mi = new MethodInvoker(PrintSomething);
    mi.BeginInvoke(null, null);

    This will work pretty well on win7 and up, but if running it on Win XP will cause a very high cpu usage and will it eat up the memory then the desktop will freeze. but just calling the method synchronously everything is fine under win XP.

    private void btn_click(object sender, EventArgs e)
    {
    PrintSomething();
    }

    Any thought about this? I will appreciate for any advice will. Thanks.

    J A 2 Replies Last reply
    0
    • G Gilbert Consellado

      I have a method something like this.

      private void PrintSomething()
      {
      //some code here
      }

      then calling this method like this

      MethodInvoker mi = new MethodInvoker(PrintSomething);
      mi.BeginInvoke(null, null);

      This will work pretty well on win7 and up, but if running it on Win XP will cause a very high cpu usage and will it eat up the memory then the desktop will freeze. but just calling the method synchronously everything is fine under win XP.

      private void btn_click(object sender, EventArgs e)
      {
      PrintSomething();
      }

      Any thought about this? I will appreciate for any advice will. Thanks.

      J Offline
      J Offline
      John Torjo
      wrote on last edited by
      #2

      Suggestions: 1. Try debugging it. Or it's not possible? 2. If not debugging, do some logging within the PrintSomething method. By what you're saying, it looks like you might end up calling PrintSomething method too many times 3. You can also ask if IsInvokeRequired first. 4. A profiler? (dotTrace comes to mind) Best, John

      -- Log Wizard - a Log Viewer that is easy and fun to use!

      G 1 Reply Last reply
      0
      • G Gilbert Consellado

        I have a method something like this.

        private void PrintSomething()
        {
        //some code here
        }

        then calling this method like this

        MethodInvoker mi = new MethodInvoker(PrintSomething);
        mi.BeginInvoke(null, null);

        This will work pretty well on win7 and up, but if running it on Win XP will cause a very high cpu usage and will it eat up the memory then the desktop will freeze. but just calling the method synchronously everything is fine under win XP.

        private void btn_click(object sender, EventArgs e)
        {
        PrintSomething();
        }

        Any thought about this? I will appreciate for any advice will. Thanks.

        A Offline
        A Offline
        Alan N
        wrote on last edited by
        #3

        mi.BeginInvoke(null, null) executes your PrintSomething() method asynchronously on a threadpool thread. Is that what you intended or did you mean to use Control.BeginInvoke(mi) to execute PrintSomething on the UI thread?

        G 1 Reply Last reply
        0
        • J John Torjo

          Suggestions: 1. Try debugging it. Or it's not possible? 2. If not debugging, do some logging within the PrintSomething method. By what you're saying, it looks like you might end up calling PrintSomething method too many times 3. You can also ask if IsInvokeRequired first. 4. A profiler? (dotTrace comes to mind) Best, John

          -- Log Wizard - a Log Viewer that is easy and fun to use!

          G Offline
          G Offline
          Gilbert Consellado
          wrote on last edited by
          #4

          Thanks for the advice, but I was end up not using asynchronous method execution if the OS is windows XP, :( it is hard to deal with some user that cant get over to their OS's and hardware.

          1 Reply Last reply
          0
          • A Alan N

            mi.BeginInvoke(null, null) executes your PrintSomething() method asynchronously on a threadpool thread. Is that what you intended or did you mean to use Control.BeginInvoke(mi) to execute PrintSomething on the UI thread?

            G Offline
            G Offline
            Gilbert Consellado
            wrote on last edited by
            #5

            Yeah i just want to execute it asynchronously, but i was end up using synchronous if it detects that the OS is XP. BTW Thanks

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups