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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. ThreadStart issue

ThreadStart issue

Scheduled Pinned Locked Moved C#
helpdata-structuresquestion
4 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
    merh
    wrote on last edited by
    #1

    Hi, I need your help to clarify the following.I try to run a method with the parameters on own thread. But I get the error. public class MyQueue { Queue myQueue = new Queue(); public void Enqueue(PacketHeader p, byte[] s) { Data data = new Data(p, s); myQueue.Enqueue(data); } } m_myQueue = new MyQueue(); Thread thread = new Thread(new ThreadStart(m_myQueue.Enqueue(????))); thread.Start(); Thanks in advanced Mehran

    S 1 Reply Last reply
    0
    • M merh

      Hi, I need your help to clarify the following.I try to run a method with the parameters on own thread. But I get the error. public class MyQueue { Queue myQueue = new Queue(); public void Enqueue(PacketHeader p, byte[] s) { Data data = new Data(p, s); myQueue.Enqueue(data); } } m_myQueue = new MyQueue(); Thread thread = new Thread(new ThreadStart(m_myQueue.Enqueue(????))); thread.Start(); Thanks in advanced Mehran

      S Offline
      S Offline
      Spacix One
      wrote on last edited by
      #2

      Wrong threading type, look at the threading articles for .NET for the correct method (note this is a pun!) to do this :) Well you could do this with properties, but if you just want to run a method this follow my above statement :D


      -Spacix All your skynet questions[^] belong to solved

      M 1 Reply Last reply
      0
      • S Spacix One

        Wrong threading type, look at the threading articles for .NET for the correct method (note this is a pun!) to do this :) Well you could do this with properties, but if you just want to run a method this follow my above statement :D


        -Spacix All your skynet questions[^] belong to solved

        M Offline
        M Offline
        merh
        wrote on last edited by
        #3

        Thanks

        S 1 Reply Last reply
        0
        • M merh

          Thanks

          S Offline
          S Offline
          Spacix One
          wrote on last edited by
          #4

          NP, just be careful and be sure to call EndInvoke on your ISyncResult object, that is if the method is should to finish even if the caller would have ended first.


          -Spacix All your skynet questions[^] belong to solved

          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