|
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)
{
if (breakLoop)
{
break;
}
}
}
}
}
catch (Exception ex)
{MessageBox.Show(ex.Message);}
finally
{
}
}
string Beautiful;
Beautiful = "ignorant";
label1.Text = "The world is full of " + Beautiful +" people.";
Why is common sense such an un-common comodity?
|
|
|
|
|
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.
|
|
|
|
|
I have a number of custom forms and controls that rely on runtime information to do their job. In cases where these items do their setup in the constructor, bad things happen when one of these is displayed in the designer.
Currently, I use the following code to determine if my item is running in the designer:
<br />
public static bool InDesignMode()<br />
{<br />
string exe = Application.ExecutablePath;<br />
if ( exe.IndexOf("devenv.exe") != -1 )<br />
{<br />
return true;<br />
}<br />
return false;<br />
}<br />
Although this works I’m wondering if there is a better way. I don’t like relying on something like a file name to make this kind of decision.
Any ideas or comments?
Thanks!
Chris
|
|
|
|
|
public class Utilities<br />
{<br />
private static bool AppRunnning = false; <br />
public static void Main(string[] args)<br />
{<br />
AppRunnning = true;<br />
Application.Run(new Form1());<br />
}<br />
public static bool InDesignMode<br />
{<br />
get { return !AppRunnning; }<br />
}<br />
}<br />
<br />
public class MyControl:UserControl<br />
{<br />
public MyControl()<br />
{<br />
if (Utilities.InDesignMode)<br />
{<br />
}<br />
else<br />
{<br />
}<br />
}<br />
}
|
|
|
|
|
Thanks!
A much cleaner solution that what I was using.
-Chris
|
|
|
|
|
You could try the Component.DesignMode property (MSDN[^])
Cheers,
Will H
|
|
|
|
|
Thanks... didnt know such existed!
- Malhar
|
|
|
|
|
One of my dialogs is behaving as though the alt key is always pressed. Typing the letter of any of the shortcuts for a button triggers the button regardless of which control currently has focus. None of the other dialogs in my app behave this way, and flicking back and forth between the affected dialog and the remainder's property pages I'm not seeing any relavant seeming differences.
|
|
|
|
|
Hi all,
Im having a problem where i need to show a dialog box(save open cancel dialog box) from a pop up aspx page. on link button click i have opened this dialog box, I have register the script to close tat pop up aspx page which is loaded with the user control.
Is it posible to close the popup window after the dialog box appears.
Please help me out.
regards
Mukilan.P.S
|
|
|
|
|
Hi all,
I want to post some data from the C# application to my blog
that exists on some site.
How can that be done?
It would be gr8 if some one could help me outin this.
Thanks
Pramod
|
|
|
|
|
If you have a formular on your blog web page, you might want to emulate a POST -reqeuest from your C# application to the webserver. You can do this with the HttpWebRequest -class.
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Usually blog platform contains "MetaBlog API" .You can interact with blog (post,retrive data) by sending/recieving XML.I guess xml-rpc.net library[^] may help you.
DevIntelligence.com - My blog for .Net Developers
|
|
|
|
|
Hi, I'd like to know if is possible to implement a KeyPress handling for a Simple Datagrid, without DataTables or DataColumns binded to it.
How can I do?
TNX
|
|
|
|
|
DataGridTextBoxColumn.TextBox.KeyPress += new .................
Live Life King Size
Alomgir Miah
|
|
|
|
|
Thank you so much!
Alessio
|
|
|
|
|
I've got a (3rd party, non fixable) application that isn't responding to Process.CloseMainWindow() What other options do I have to force it to shut down when the app that launched it is closing?
|
|
|
|
|
|
OK. I assume there's a way to interop out and get a list of all the processes on the machine so I can kill the other 3 processes associated with the app. They've all got constant names, and there can only be a single instance of each which should make things easier, or less difficult at anyrate.
|
|
|
|
|
If they have constant names then you can use the static method Process.GetProcessesByName which will return an array of processes (which match the name you specified) that you can then mercilessly kill.
You could also use GetProcesses if you prefer, get all the processes and then iterate through them to find all the ones you need to kill.
Just be aware that kill forces the process to stop and may result in abnormal termination. So be careful not to kill a process while it's doing something important (like writing to a file).
|
|
|
|
|
I've got a warning about dataloss advising the user to properly shut the app down on my end before doing the kill. Unfortunately I don't have any way to check if the problem app's doing any file IO or not.
|
|
|
|
|
Hey howzit,
at the moment i use the following code:
System.Diagnostics.Process.Start("mailto:test@test.com");
to launch the mail client, but I wanna specify which files to attach PROGRAMMICALLY. So for example my user is reading a PDF in my application and wants to send it to someone, it must attach the relevant PDF to a new email.
Aparently one needs to make API calls and stuff, can anyone help...keep it simple as possible please
|
|
|
|
|
mailto:someone@foo.com?subject=TEST&body=SOMETEXT&attachment="/SOMEFILE.TXT"
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
hey greg,
thanks for the help, but that code doesn't work. I need to specify where on the hdd the file is and I can't even compile with that code, can you perhaps test it out on your machine and give me the entire piece of code, that would great.
Thanks a lot!
|
|
|
|
|
Hi
I have a problem with disabling a button.
When i need to disable a button then i do not want the DrawImageDisabled function to be called. Instead i just need it to be replaced with the image i provide. How can this be handled?
Please help me out in this.
Thanks and Regards
Madhu
|
|
|
|
|
Maybe, when the event is triggered to disable it, replace the image with the one you want, and then put an if() clause in the OnClick event to say if the image is X (or a bool you have attatched to it) then do this, otherwise break.
Regards
James
|
|
|
|