Hi I am trying to call a Sub from another thread but it always throwing me an error: Cross Thread is not valid.
here is the Sub I am calling from other thread.
vb Code:
Private Delegate Sub AppendToLogInvoker(ByVal strText As Object, ByVal color As Integer)vb Code:
Private Sub WriteToLog(ByVal strText As Object, ByVal color As Integer) 'As Object If Me.Log.InvokeRequired Then Me.Log.Invoke(New AppendToLogInvoker(AddressOf WriteToLog), strText, color) End If Me.Log.SelectionStart = Len(Log.Text) Me.Log.SelectionColor = System.Drawing.ColorTranslator.FromOle(color) Me.Log.SelectedText = strText Me.Log.SelectionStart = Len(Log.Text) Me.Log.SelectedText = vbCrLf End Sub
I am calling that on other thread with this:
vb Code:
WriteToLog(" [" & System.DateTime.Now.ToString("yyyy/MM/dd hh:mm:ss") & "] " _ & "ERROR: Sending failed! " _ , System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.Red))
I am getting stock at this point
vb Code:
Me.Log.SelectionStart = Len(Log.Text)


Reply With Quote
