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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. Visual Basic
  4. Problems with multithreading - HELP [modified]

Problems with multithreading - HELP [modified]

Scheduled Pinned Locked Moved Visual Basic
sysadminhelpquestion
2 Posts 1 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.
  • D Offline
    D Offline
    david mindplay com
    wrote on last edited by
    #1

    First of all, let me state that I am new to multithreading. I am working on a project that makes constant queries to a network device via a tcp connection. These queries can generally take about a third to a half a second to complete. As it stands I am creating several (4-5) separate threads that loop and make queries then report the result data to my main thread. Each thread maintains it's own tcp connection to the device. Each of the threads is set to sleep for an entire second each loop cycle, each of the threads is set to lowest priority. Yet CPU usage is through the roof. And i'm using a modern 3+ ghz machine. Why is my application eating up so much CPU time? Is there a cure for this, am I doing something wrong? Please help. -- modified at 19:01 Friday 25th August, 2006

    D 1 Reply Last reply
    0
    • D david mindplay com

      First of all, let me state that I am new to multithreading. I am working on a project that makes constant queries to a network device via a tcp connection. These queries can generally take about a third to a half a second to complete. As it stands I am creating several (4-5) separate threads that loop and make queries then report the result data to my main thread. Each thread maintains it's own tcp connection to the device. Each of the threads is set to sleep for an entire second each loop cycle, each of the threads is set to lowest priority. Yet CPU usage is through the roof. And i'm using a modern 3+ ghz machine. Why is my application eating up so much CPU time? Is there a cure for this, am I doing something wrong? Please help. -- modified at 19:01 Friday 25th August, 2006

      D Offline
      D Offline
      david mindplay com
      wrote on last edited by
      #2

      Fixed. Problem had nothing to do with multithreading. Code was getting stuck in a while loop. My own dumb fault. A single call to System.Threading.Thread.Sleep inside the while loop brought CPU usage down from 85-100% to 12-18%.

      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