Inherits System.ServiceProcess.ServiceBase
Protected Overrides Sub OnStart(ByVal args() As String)
End Sub
Protected Overrides Sub OnStop()
End Sub
sw.Flush()
Dim watcherThread As Thread = New Thread(AddressOf listener)
Protected Overrides Sub OnStart(ByVal args() As String)
WriteToLog("logs\webproxy.log", "Service started")
watcherThread.Start()
End Sub
Private Sub listener()
Dim tcplistener As New TcpListener(port)
tcplistener.Start()
WriteToLog("logs\webproxy.log", "Listening on port " & port.ToString)
While True
Dim socket As Socket = tcplistener.AcceptSocket()
Dim webproxy As New WebProxy(socket)
Dim thread As New Thread(New ThreadStart(AddressOf webproxy.runproxy))
thread.Start()
End While
End Sub
Public Sub WriteToLog(ByVal Filename As String, ByVal Comment As String)
Dim sw As System.IO.StreamWriter
Try
sw = New System.IO.StreamWriter(Filename, True)
sw.WriteLine(Date.Now & " " & Comment)
sw.Flush()
Catch e As Exception
Finally
If Not sw Is Nothing Then sw.Close()
End Try
End Sub
I need the refrence to Windows.Forms to interact with the desktop in order to write to the log files.