Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. invoke to marshal

invoke to marshal

Scheduled Pinned Locked Moved Visual Basic
help
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Makniteasy
    wrote on last edited by
    #1

    i was told i need to use invoke to marshal to fix this exception : Control 'TxtFolderActivity' accessed from a thread other than the thread it was created on. i cant seem to figure it out. here is the snippet of code where i need the invoke. Private Sub logchange(ByVal source As Object, ByVal e As _ System.IO.FileSystemEventArgs) If e.ChangeType = IO.WatcherChangeTypes.Changed Then TxtFolderActivity.Text &= "File " & e.FullPath & _ " has been modified" & vbCrLf End If If e.ChangeType = IO.WatcherChangeTypes.Created Then TxtFolderActivity.Text &= "File " & e.FullPath & _ " has been created" & vbCrLf End If If e.ChangeType = IO.WatcherChangeTypes.Deleted Then TxtFolderActivity.Text &= "File " & e.FullPath & _ " has been deleted" & vbCrLf End If End Sub Makniteasy

    J 1 Reply Last reply
    0
    • M Makniteasy

      i was told i need to use invoke to marshal to fix this exception : Control 'TxtFolderActivity' accessed from a thread other than the thread it was created on. i cant seem to figure it out. here is the snippet of code where i need the invoke. Private Sub logchange(ByVal source As Object, ByVal e As _ System.IO.FileSystemEventArgs) If e.ChangeType = IO.WatcherChangeTypes.Changed Then TxtFolderActivity.Text &= "File " & e.FullPath & _ " has been modified" & vbCrLf End If If e.ChangeType = IO.WatcherChangeTypes.Created Then TxtFolderActivity.Text &= "File " & e.FullPath & _ " has been created" & vbCrLf End If If e.ChangeType = IO.WatcherChangeTypes.Deleted Then TxtFolderActivity.Text &= "File " & e.FullPath & _ " has been deleted" & vbCrLf End If End Sub Makniteasy

      J Offline
      J Offline
      Joshua Quick
      wrote on last edited by
      #2

      You're not allowed to interact with a Form on a separate thread. What you need to do is call BeginInvoke(). What this will do is push a delegate to the end of the Windows message queue. That delegate will be invoked on the UI thread, which will allow you to safely write your string to the TextBox. The following article has more information. See the code example at the bottom. http://www.codeproject.com/csharp/begininvoke.asp[^]

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups