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. ThreadStart Wrappers vs. State

ThreadStart Wrappers vs. State

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

    I have a class that performs a single atomic, stateless task. However, I need to multithread this class in a barrage against a test server, and the ThreadStart delegate constructor must have a parameterless method. I have two alternatives: to add state to my original class and set this state through properties before starting the thread, or isolating the state in a wrapper class whose parameterless method calls the parameterful method in the original class? What say ye? The DJ's took pills to stay awake and play for seven days. - Jim Morrison, Black Polished Chrome.

    S 1 Reply Last reply
    0
    • P ProffK

      I have a class that performs a single atomic, stateless task. However, I need to multithread this class in a barrage against a test server, and the ThreadStart delegate constructor must have a parameterless method. I have two alternatives: to add state to my original class and set this state through properties before starting the thread, or isolating the state in a wrapper class whose parameterless method calls the parameterful method in the original class? What say ye? The DJ's took pills to stay awake and play for seven days. - Jim Morrison, Black Polished Chrome.

      S Offline
      S Offline
      S Senthil Kumar
      wrote on last edited by
      #2

      I'd go with the latter. It avoids synchronization issues which can happen when properties are being set and multiple threads are started. Regards Senthil _____________________________ My Blog | My Articles | WinMacro

      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