1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
| Private Sub ping(ByVal obj As Object)
Dim ip = New String(obj)
Dim m As machine
Try
Dim p As New Net.NetworkInformation.Ping
Dim r = p.Send(ip, 150)
If r.Status = Net.NetworkInformation.IPStatus.Success Then
m = New machine
m.hostname = System.Net.Dns.GetHostEntry(ipOrHostname).HostName
m.ip= System.Net.Dns.GetHostEntry(ipOrHostname).AddressList(0).ToString
m.EtatMachine = True
etatMachine.Add(m)
Else
m = New machine
m.EtatMachine= False
If ipAddr.isIPv4(ip) Then
m.ip= ip
Else
m.hostname = ip
End If
etatMachine.Add(m)
End If
Catch ex As Exception
m = New machine
If ipAddr.isIPv4(ip) Then
m.ip= ip
Else
m.hostname = ip
End If
m.EtatMachine = False
etatMachine.Add(m)
End Try
end Sub
Private _verrou As New Object
Private Sub AddToCollectionThreadSafe(ByVal m As machine)
SyncLock _verrou
etatMachine.Add(m)
End SyncLock
End Sub
Public ReadOnly Property Etat()
Get
Return etatMachine
End Get
End Property |