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