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 backgroundWorker make code slower?

Does backgroundWorker make code slower?

Scheduled Pinned Locked Moved C#
visual-studiotestingbeta-testingquestion
4 Posts 2 Posters 0 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.
  • M Offline
    M Offline
    MichCl
    wrote on last edited by
    #1

    I am testing code that uses backgroundWorker. A similar application run on a different computer runs code that is practically the same, and is faster, but doesn't use backgroundWorker. Could the backgroundWorker be taking longer than code that doesn't use the backgroundWorker? Other differences are 32 bit vs 64 bit(mine)computer. My code also uses more dll's, but using a profiler with my code, the part that was taking long was a repeated call to an external dll, which the other code also does.

    P 1 Reply Last reply
    0
    • M MichCl

      I am testing code that uses backgroundWorker. A similar application run on a different computer runs code that is practically the same, and is faster, but doesn't use backgroundWorker. Could the backgroundWorker be taking longer than code that doesn't use the backgroundWorker? Other differences are 32 bit vs 64 bit(mine)computer. My code also uses more dll's, but using a profiler with my code, the part that was taking long was a repeated call to an external dll, which the other code also does.

      P Offline
      P Offline
      PIEBALDconsult
      wrote on last edited by
      #2

      If it's done wrong, sure. Plus multi-threading adds more complexity which can mean things like checking a semaphore and locking. This could lead to lessened performance, but that could just mean that the problem isn't suited to multi-threading. We'd need to see the code to be sure.

      M 1 Reply Last reply
      0
      • P PIEBALDconsult

        If it's done wrong, sure. Plus multi-threading adds more complexity which can mean things like checking a semaphore and locking. This could lead to lessened performance, but that could just mean that the problem isn't suited to multi-threading. We'd need to see the code to be sure.

        M Offline
        M Offline
        MichCl
        wrote on last edited by
        #3

        Maybe the problem is with how I create the backgroundWorker. From my form class, I am doing the following (I create two of these..one for each form tab):

        if (!backgroundWorker1.IsBusy)
        {
        try
        {
        backgroundWorker1.RunWorkerAsync(); //cr
        }
        }

        Is there a way I can still have the user able to hit a button on the form, yet have the backgroundWorkers hog more of the processor so they can have priority over the form and other things on the computer?

        P 1 Reply Last reply
        0
        • M MichCl

          Maybe the problem is with how I create the backgroundWorker. From my form class, I am doing the following (I create two of these..one for each form tab):

          if (!backgroundWorker1.IsBusy)
          {
          try
          {
          backgroundWorker1.RunWorkerAsync(); //cr
          }
          }

          Is there a way I can still have the user able to hit a button on the form, yet have the backgroundWorkers hog more of the processor so they can have priority over the form and other things on the computer?

          P Offline
          P Offline
          PIEBALDconsult
          wrote on last edited by
          #4

          I just use Threads, not BackgroundWorkers, and I always set them for lower Priority.

          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