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. Web Development
  3. ASP.NET
  4. Threading

Threading

Scheduled Pinned Locked Moved ASP.NET
tutorial
3 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
    miniThomas
    wrote on last edited by
    #1

    Can anyone give mi code example of Threading using Thread.priority(),Thread.sleep(),Thread.CurrentThread,Thread.Start() Mini Thomas

    S 1 Reply Last reply
    0
    • M miniThomas

      Can anyone give mi code example of Threading using Thread.priority(),Thread.sleep(),Thread.CurrentThread,Thread.Start() Mini Thomas

      S Offline
      S Offline
      suketh
      wrote on last edited by
      #2

      hi, **Creating Threads :**Create new instance of Thread object. Thread constructor accepts one parameters which is delegate Thread dummyThread = new Thread( new ThreadStart(dummyFunction) ); Executing Thread: To run this thread us the method start provided by Threading namespace DummyThread.Start (); Joining Threads: There is always the requirement to join thread specially when a thread depends on some other thread for completing its task. Lets assume that DummyThread has to wait for DummyPriorityThread to complete its task and then run again. In this case we need to do the following: DummyPriorityThread.Join() ; Suspending Thread: This will suspend the thread for the given number of seconds DummyPriorityThread.Sleep(); **Killing Thread:**When there is a need to kill a thread use the following to achieve the same. DummyPriorityThread.Abort(); hope this will give u some idea... thanks, Suketh

      M 1 Reply Last reply
      0
      • S suketh

        hi, **Creating Threads :**Create new instance of Thread object. Thread constructor accepts one parameters which is delegate Thread dummyThread = new Thread( new ThreadStart(dummyFunction) ); Executing Thread: To run this thread us the method start provided by Threading namespace DummyThread.Start (); Joining Threads: There is always the requirement to join thread specially when a thread depends on some other thread for completing its task. Lets assume that DummyThread has to wait for DummyPriorityThread to complete its task and then run again. In this case we need to do the following: DummyPriorityThread.Join() ; Suspending Thread: This will suspend the thread for the given number of seconds DummyPriorityThread.Sleep(); **Killing Thread:**When there is a need to kill a thread use the following to achieve the same. DummyPriorityThread.Abort(); hope this will give u some idea... thanks, Suketh

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

        protected void Page_Load(object sender, EventArgs e) { Thread pthread1 = new Thread(new ThreadStart(Thread1)); Thread pthread2 = new Thread(new ThreadStart(Thread2)); pthread1.Start(); } public void Thread1() { string strThread1; strThread1 = "I am first thread."; for (int i=0;i<5;i++ ) { ListBox1.Items.Add(strThread1); if(i==3) { pthread2.Join(); } } } public void Thread2() { string strThread2; strThread2 = "I am second thread."; for (int j=0;j<5;j++) { ListBox1.Items.Add(strThread2); } } I want to call pthread2.Join() in public void Thread1() but gives error also i need to access pthread1 in public void Thread2()..How to do this? Mini Thomas

        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