I'm simply trying to keep a log list for my application events.
I'm trying to send text to the log from a seperate thread with the following code:
Imports System.Threading
Public Class Main
Private worker1 As Thread
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
worker1 = New Thread(AddressOf test)
worker1.Start()
log(logconsole, "Ready")
test()
End Sub
Private Delegate Sub AppendTextBoxDelegate(ByVal TB As TextBox, ByVal txt As String)
Private Sub log(ByVal TB As TextBox, ByVal txt As String)
If TB.InvokeRequired Then
TB.Invoke(New AppendTextBoxDelegate(AddressOf log), New Object() {TB, txt})
Else
TB.AppendText(txt)
End If
End Sub
Sub test()
log(logconsole, "text")
End Sub
End Class
this almost works except it prints the test() output twice...
I only need it printed once.