Invoke and Dispose help please

Jimmy22

Member
Joined
Mar 27, 2008
Messages
15
Programming Experience
Beginner
Could some on please explain how to code for the invoke and dispose syntax please i am having problems with this code

VB.NET:
 Private Sub logchange(ByVal source As Object, ByVal e As System.IO.FileSystemEventArgs)
        If e.ChangeType = WatcherChangeTypes.Changed Then
            Me.txtlog.Text &= "File " & e.FullPath & "has been modified" & vbCrLf
        End If

        If e.ChangeType = WatcherChangeTypes.Created Then
            Me.txtlog.Text &= "File " & e.FullPath & "has been created" & vbCrLf
        End If

        If e.ChangeType = WatcherChangeTypes.Deleted Then
            Me.txtlog.Text &= "File " & e.FullPath & "has been deleted" & vbCrLf
        End If

    End Sub

    'This is the code for handling the Renamed event raised by the FileSystemWatcher class:
    Public Sub logrename(ByVal source As Object, ByVal e As System.IO.RenamedEventArgs)
        Me.txtlog.Text &= "File" & e.OldName & " has been renamed to " & e.Name & vbCrLf
    End Sub
And the error is:
"Cross-thread operation not valid: Control 'txtlog' accessed from a thread other than the thread it was created on."

From what i have read up on the error. I need to invoke and dispose any ideas :confused::confused::confused::confused: i know i dont......


Thanks in advance

Jimmy22
 
Last edited by a moderator:
Back
Top