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. C#
  4. Stopping a Thread

Stopping a Thread

Scheduled Pinned Locked Moved C#
help
1 Posts 1 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.
  • N Offline
    N Offline
    nasambur
    wrote on last edited by
    #1

    Hi, I'm writing a LoadGenerator application, in which for a specific period of time certain no.of Threads are created and executes simultaneously.. That i call as RampUp threads. After sleeping for a sustain period (10secs) of time.. I want to RampDown threads, that is i want to kill the threads one by one.. I have defined an ArrayList object alThreads to maintain the Threads list.. RampUp() method

    public void RampUp()
    {
      for(int i=0; i<10; i++)
      {
        Thread thread = new Thread(ExecuteSingleThread);
        thread.Start();
        if(alThread.Contains(thread) == false)
        {
          alThreads.Add(thread);
        }
        Thread.Sleep(5000);
      }
    }
    

    The below code kills the thread every five second.. RampDown() method

    public void RampDown()
    {
    for(int i=0;i
    

    Now the problem is after killing the first thread, all the remaining threads doesn't executes the code inside it.. Please help me.. regards, nas

    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