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. How does 1 thread multiply into 3 threads???

How does 1 thread multiply into 3 threads???

Scheduled Pinned Locked Moved C#
helpquestioncsharpdebuggingregex
2 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.
  • W Offline
    W Offline
    WetRivrRat
    wrote on last edited by
    #1

    Ok, trying to loop through a treeview and create connection to each node(pc). Am running a new thread to do this loop as it is taxing on the application.

    PcTree = new Thread(new ThreadStart(enumThread));
    PcTree.Name = "PollPCList";
    PcTree.Start();

    When I look at the output of my node looping I consitently find 3 connections to each node. After trying to step thru the debugger i find that sometimes it does keep this pattern(3 connections), other times i only see one loop for each node. (how odd is that?) -- why is this happening? is it due to the fact that i'm running this on a dual-proc pc? now, that obviously is the problem, here is my question: if i haven't done something wrong with my code and i'm stuck with this 'triple threat thread' then is it possible that i increment the foreach loop so that i process 3 different nodes instead of just one node 3 times?

    private void enumThread()
    {
    enumPCtree(PCmonitorTree.Nodes);
    }

    private void enumPCtree(TreeNodeCollection t)
    {
    try
    {
    foreach ( TreeNode tr in t)
    {
    if (tr.Text.IndexOf("PC")!= -1)
    {
    tr.Nodes.Equals(tr.NextNode);
    }
    else
    {
    ServerName = tr.Text;
    try
    {
    HostIP = System.Net.Dns.GetHostByName(ServerName);
    PcIpAddress = HostIP.AddressList[0].ToString();
    }
    catch
    {}
    finally
    {enumPCtree(tr.Nodes);}
    if (PcIpAddress != null)
    {
    //do scan
    if (breakLoop)
    {
    break;
    }
    }
    }
    }
    }
    catch (Exception ex)
    {MessageBox.Show(ex.Message);}

    	finally
    	{
    	//End Scan
    	}
    

    }

    string Beautiful; Beautiful = "ignorant"; label1.Text = "The world is full of " + Beautiful +" people."; Why is common sense such an un-common comodity?

    W 1 Reply Last reply
    0
    • W WetRivrRat

      Ok, trying to loop through a treeview and create connection to each node(pc). Am running a new thread to do this loop as it is taxing on the application.

      PcTree = new Thread(new ThreadStart(enumThread));
      PcTree.Name = "PollPCList";
      PcTree.Start();

      When I look at the output of my node looping I consitently find 3 connections to each node. After trying to step thru the debugger i find that sometimes it does keep this pattern(3 connections), other times i only see one loop for each node. (how odd is that?) -- why is this happening? is it due to the fact that i'm running this on a dual-proc pc? now, that obviously is the problem, here is my question: if i haven't done something wrong with my code and i'm stuck with this 'triple threat thread' then is it possible that i increment the foreach loop so that i process 3 different nodes instead of just one node 3 times?

      private void enumThread()
      {
      enumPCtree(PCmonitorTree.Nodes);
      }

      private void enumPCtree(TreeNodeCollection t)
      {
      try
      {
      foreach ( TreeNode tr in t)
      {
      if (tr.Text.IndexOf("PC")!= -1)
      {
      tr.Nodes.Equals(tr.NextNode);
      }
      else
      {
      ServerName = tr.Text;
      try
      {
      HostIP = System.Net.Dns.GetHostByName(ServerName);
      PcIpAddress = HostIP.AddressList[0].ToString();
      }
      catch
      {}
      finally
      {enumPCtree(tr.Nodes);}
      if (PcIpAddress != null)
      {
      //do scan
      if (breakLoop)
      {
      break;
      }
      }
      }
      }
      }
      catch (Exception ex)
      {MessageBox.Show(ex.Message);}

      	finally
      	{
      	//End Scan
      	}
      

      }

      string Beautiful; Beautiful = "ignorant"; label1.Text = "The world is full of " + Beautiful +" people."; Why is common sense such an un-common comodity?

      W Offline
      W Offline
      Wjousts
      wrote on last edited by
      #2

      How and where does this process get started? Is it within an event? Is that event getting called multiple times?

      wetrivrrat wrote:

      it due to the fact that i'm running this on a dual-proc pc?

      errmm...I'd have to say no.

      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