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. .NET (Core and Framework)
  4. Windows Form UI and Thread Safety on Controls

Windows Form UI and Thread Safety on Controls

Scheduled Pinned Locked Moved .NET (Core and Framework)
designquestion
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.
  • Y Offline
    Y Offline
    Yadrif
    wrote on last edited by
    #1

    Hello All, I'm working on a project where I'll have multiple controls on a Windows form that may get updated when messages are received on a socket being listened on by a worker thread or the controls might get updated from the main thread. The way I currently understand it is I need to set the controls properties using a delagate if control.InvokeRequired is true. How could this be done without having to have a delagate method for each control on the form? There are many of them and they all could be updated from the worker thread. All advice is appreciated. Thanks.

    D 1 Reply Last reply
    0
    • Y Yadrif

      Hello All, I'm working on a project where I'll have multiple controls on a Windows form that may get updated when messages are received on a socket being listened on by a worker thread or the controls might get updated from the main thread. The way I currently understand it is I need to set the controls properties using a delagate if control.InvokeRequired is true. How could this be done without having to have a delagate method for each control on the form? There are many of them and they all could be updated from the worker thread. All advice is appreciated. Thanks.

      D Offline
      D Offline
      Dustin Metzgar
      wrote on last edited by
      #2

      Try reading up on the SynchronizationContext class. This article[^] might be a good start.

      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