Click here to Skip to main content
15,915,163 members
Home / Discussions / C#
   

C#

 
AnswerRe: form apearance PinPopular
Dan Mos28-Aug-10 8:29
Dan Mos28-Aug-10 8:29 
AnswerRe: form apearance Pin
PIEBALDconsult29-Aug-10 5:45
mvePIEBALDconsult29-Aug-10 5:45 
AnswerRe: form apearance Pin
Abhinav S29-Aug-10 6:37
Abhinav S29-Aug-10 6:37 
AnswerRe: form apearance Pin
Pete O'Hanlon29-Aug-10 9:43
mvePete O'Hanlon29-Aug-10 9:43 
GeneralRe: form apearance Pin
ronakT4-Sep-10 9:38
ronakT4-Sep-10 9:38 
QuestionLoad print templates Pin
dSolariuM28-Aug-10 1:42
dSolariuM28-Aug-10 1:42 
QuestionRe: Load print templates Pin
Yusuf28-Aug-10 4:55
Yusuf28-Aug-10 4:55 
AnswerRe: Load print templates Pin
Abhinav S28-Aug-10 5:22
Abhinav S28-Aug-10 5:22 
QuestionVisual Studio 2010 crashes when designer finishes loading Pin
WebMaster28-Aug-10 1:03
WebMaster28-Aug-10 1:03 
AnswerRe: Visual Studio 2010 crashes when designer finishes loading Pin
Philippe Mori28-Aug-10 2:39
Philippe Mori28-Aug-10 2:39 
GeneralRe: Visual Studio 2010 crashes when designer finishes loading Pin
WebMaster28-Aug-10 4:03
WebMaster28-Aug-10 4:03 
GeneralRe: Visual Studio 2010 crashes when designer finishes loading Pin
WebMaster28-Aug-10 4:40
WebMaster28-Aug-10 4:40 
Questionrun a method on other application Pin
solomon8528-Aug-10 0:47
solomon8528-Aug-10 0:47 
AnswerRe: run a method on other application Pin
Eddy Vluggen28-Aug-10 3:16
professionalEddy Vluggen28-Aug-10 3:16 
AnswerRe: run a method on other application Pin
dan!sh 28-Aug-10 3:37
professional dan!sh 28-Aug-10 3:37 
AnswerRe: run a method on other application Pin
Abhinav S28-Aug-10 5:26
Abhinav S28-Aug-10 5:26 
QuestionBacking up database file using SMO error Pin
gamer112727-Aug-10 16:52
gamer112727-Aug-10 16:52 
Questionbuilding a win form application problem Pin
mrkeivan27-Aug-10 11:37
mrkeivan27-Aug-10 11:37 
AnswerRe: building a win form application problem Pin
Not Active27-Aug-10 12:01
mentorNot Active27-Aug-10 12:01 
QuestionWin7 No PingCompletedCallback on timeout? Pin
Gavin Coates27-Aug-10 7:44
Gavin Coates27-Aug-10 7:44 
Hey guys,

I wrote a network scanning tool a few years ago, which pings a list of IP addresses. I recently moved to Windows 7, and have noticed some strange behaviour in the program. My ping code is as follows:

public void pingIP(int IP)
        {
            AutoResetEvent waiter = new AutoResetEvent (false);
            string IPaddress = IPpart1.Value.ToString() + "." + IPpart2.Value.ToString() + "." + IPpart3.Value.ToString() + "." + IP;
            IPAddress IPa = IPAddress.Parse(IPaddress);
            
            Debug.WriteLine("Pinging " + IP.ToString());
            
            Ping ping = new Ping();
            ping.PingCompleted += new PingCompletedEventHandler(PingCompletedCallback);

            ping.SendAsync(IPa, waiter);
            
        }


This then calls PingCompletedCallback when it recieves a response:
public  void PingCompletedCallback(object sender, PingCompletedEventArgs e)
        {
            

            PingReply reply = e.Reply;
                // get the IP that was pinged
                string IP = reply.Address.ToString();
                
                if(IP != "0.0.0.0")
                {
	                string[] IParray = IP.Split('.');
	                int iIP = Int32.Parse(IParray[3]);
	                if (reply.Status == IPStatus.Success)
	                    pingResult[iIP] = reply.RoundtripTime.ToString();
	                else
	                    pingResult[iIP] = "X";
	            
	                Debug.WriteLine("Ping Reply From " + IP.ToString() + " Time: " + pingResult[iIP]);
	
	                // check if the last ping (255) has been reveived and mark the ping complete flag if so
	                if (iIP == 255)
	                {
	                    pingComplete = true;
	                    lblStatus.Text = "Ping Complete";
	                }
                }
                
                
                
            ((AutoResetEvent)e.UserState).Set();
        }


Now, under Windows XP this worked fine, PingCompletedCallback was called for every ping I sent - either with a response, or with a timeout. I could then set the value as required. However, under Win7, PingCompletedCallback only seems to be called when a successful response is received. I have also noticed I recieve a lot of replies from "0.0.0.0", as well as multiple replies from the IP the machine is running on (10.0.0.4)

I have a second screen for doing a detailed ping on a single IP, which doesnt use a callback function, and it works fine when no response is received:

public void startPing(IPAddress IP)
        {
            
            
            textStatus.Text += "Pinging " + IP.ToString() + "...";
            this.Refresh();

            Ping ping = new Ping();

            PingReply reply = ping.Send(IP);
            if (reply.Status == IPStatus.Success)
                textStatus.Text += " Time: " + reply.RoundtripTime.ToString() + "\r\n";
            else
                textStatus.Text += reply.Status.ToString() + "\r\n";
        }


Has nayone seen anything like this before? Im a little confused!
QuestionCustom file type Pin
Etienne_12327-Aug-10 5:29
Etienne_12327-Aug-10 5:29 
AnswerRe: Custom file type Pin
OriginalGriff27-Aug-10 5:46
mveOriginalGriff27-Aug-10 5:46 
GeneralRe: Custom file type Pin
Etienne_12327-Aug-10 6:14
Etienne_12327-Aug-10 6:14 
AnswerRe: Custom file type Pin
Chris Trelawny-Ross27-Aug-10 5:47
Chris Trelawny-Ross27-Aug-10 5:47 
AnswerRe: Custom file type Pin
OriginalGriff27-Aug-10 5:51
mveOriginalGriff27-Aug-10 5:51 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.