hi,
I have a 'ping' program in .net 2003, and also a timer source code in .net 2003.
When the program is running, i want it to 'ping' the ip address automatically for every 2 minutes. But I don't know how to write it in code.
Can someone please help me
Thank You

'ping' automatically
LazyGenius
I very sorry because I'm doing it in visual basic project, is it ok if i can have the above code in visual basic project Sorry to caused any trouble.
Bryan Miller
That's cool, I will take a look.
But i want it in visual basic.net 2003.
thanks
Bil Muh
There's an example of Ping here:
http://www.csharphelp.com/archives/archive6.html
ali_ba82
Here is my code:
Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Dim objPingHost1 As New clsPing
Dim lngPingReply1 As Long
txtHost.Text = "152.226.142.3"
objPingHost1.TimeOut = 5000
objPingHost1.DataSize = 32
objPingHost1.Host = Trim(Me.txtHost.Text)
'Me.txtLog.Text = "Trying to ping" & Trim(Me.txtHost.Text) & "..."
lngPingReply1 = objPingHost1.Ping()
If (lngPingReply1 = objPingHost1.PING_ERROR) Then
Me.txtLog.Text &= vbCrLf & "Camera2 OFF" '& objPingHost1.GetLastError.Description
Else
Me.txtLog.Text &= vbCrLf & "Camera2 ON" '& lngPingReply1 & "msec"
End If
End Sub
Thanks yoU.
nicklebum
Can you explain a bit more
I don't understand this part, 'and then subscribe to the Tick event of the timer where you call the ping code'
thanks
Vaxman2
Stefan P
Drag and drop a timer to a Windows Form.Right click on it and click properties.In the property grid that comes up,set Interval to 12000.And click on the events tab(yellow in color)and double click on "Tick".You will see code such as
private
void timer1_Tick(object sender, System.EventArgs e){
//Write ping code here
}
This will execute the ping code once in 120 sec.
altja
You can use both, the timer as mintioned code or use windows schedule to run the code"or At command in the cmd.exe".
waheedahmed
hi,
I don't understand what you mean. Can you explain further
serghio
I mean you have two ways to achieve this goal:
1) by writing the code directly into your project (using timer control). The Guys already wrote this in the replies.
2) by using windows schedule tool (in the control panel you'll find the tool "Scheduled Tasks"), use it from GUI or from Command line "at.exe".
I hope this makes things clear!
JerryCic
Add a timer to your form.(say timer1)
timer1.Interval = 120000;(120*1000 ms)
and then subscribe to the Tick event of the timer where you call the ping code.
Let me know if this is what you were looking for