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
| Imports System.IO
Public Class Form1
Private WithEvents IP As InterProcess
Private WithEvents IP2 As InterProcess
Dim ancien As String = ""
Dim eA As Double = 0
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
IP = New InterProcess("Form1")
IP2 = New InterProcess("Form2")
Timer1.Start()
Timer2.Start()
File.WriteAllText("result.txt", "Surveillance démarrée " & Date.Now & vbNewLine)
File.WriteAllText("result2.txt", "Surveillance démarrée " & Date.Now & vbNewLine)
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Try
If IP.Stream <> "" And IP.Stream = ancien Then
File.AppendAllText("result.txt", Date.Now.ToLongTimeString & " Non Connecté" & vbNewLine)
File.AppendAllText("result2.txt", Date.Now.ToLongTimeString & IP.Stream & " " & ancien & vbNewLine)
ElseIf IP.Stream <> ancien Then
File.AppendAllText("result.txt", Date.Now.ToLongTimeString & " Connecté" & IP.Stream & " " & ancien & vbNewLine)
End If
ancien = IP.Stream
Catch ex As Exception
End Try
End Sub
Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
IP2.Stream = eA
If eA < 99 Then
eA += 1
Else
eA = 0
End If
End Sub
End Class |
Partager