Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Public Class Confictura
- Dim Writer As New ThreadSafeWriter
- Dim WithEvents DownloadTimer As New System.Timers.Timer
- Public Sub Main() Handles MyBase.Loaded
- ' Increase max concurrent connectinos above default
- System.Net.ServicePointManager.DefaultConnectionLimit = 100
- DownloadTimer.Interval = 50
- DownloadTimer.AutoReset = True
- DownloadTimer.Start()
- End Sub
- Public Sub GetCounterValue() Handles DownloadTimer.Elapsed
- Try
- Dim Client As New WebClient
- Dim Response As String = Client.DownloadString("http://www.conficturaindustries.com/c.php")
- Response = Response.Replace("<img src=""images/", "")
- Response = Response.Replace(".gif", "")
- Response = Response.Replace(""">", "")
- Writer.WriteLine(Now.Ticks & "," & Response)
- Catch ex As Exception
- End Try
- End Sub
- End Class
- Public Class ThreadSafeWriter
- Dim File As New IO.FileStream("counter.csv", IO.FileMode.Append)
- Dim Writer As New IO.StreamWriter(File)
- Public Sub WriteLine(Data As String)
- SyncLock Writer
- Writer.WriteLine(Data)
- End SyncLock
- End Sub
- Public Sub Close()
- Try
- Writer.Close()
- File.Close()
- Catch ex As Exception
- End Try
- End Sub
- End Class
Add Comment
Please, Sign In to add comment