title: Thread Sequence using AutoResetEvent
body: <p>I am having a Collection(List) object which contains Enums and assigned with one class. I have a main class with operations relating with the Enums Defined. I am creating 3 threads and calling the same method of the above class.I want to sequnce btw the threads in different ways, but my threads are not getting moving as required. Attaching the sample code</p>
  
  <pre><code>for(interalIterator=0;interalIterator&lt;coll.NodeList.Count;interalIterator++)
  {   
      Console.WriteLine(threadid +"  : " + "Waitting");
  
      while(coll.processcompleted.WaitOne())
      {
          Console.WriteLine(threadid + "  : Thread Load port ID " + 
                    coll.NodeList[interalIterator].LoadPortID);             
          if (carrieroperation == Operations.L1)
          {
              lock (this)
              {
                  if (coll.NodeList[interalIterator].LoadPortID == p.LoadPorts)
                  {
                      Console.WriteLine(threadid + "  : " + 
                              "Entered  operation for LP:" + 
                              p.LoadPorts.ToString());
                      SetNextEnum(coll, interalIterator);
  
                      //CheckCollectionEnd(interalIterator);
                      coll.processcompleted.Set();
                      Console.WriteLine(threadid + "  : " + 
                             "Released Thread - Load operation for LP:" +
                              p.LoadPorts.ToString());
                  }
              }
          }
          else if (carrieroperation == Operations.P1)
          {
              lock (this)
              {
                  if(coll.NodeList[interalIterator].LoadPortID == p.LoadPorts)
                  {
                      Console.WriteLine(threadid + "  : " + 
                          "Entered  operation for LP:" + 
                          p.LoadPorts.ToString());
                      SetNextEnum(coll, interalIterator);
                      coll.processcompleted.Set();
                  }
              }
          }
          else if (carrieroperation == Operations.C1)
          {
              lock (this)
              {
                  if(coll.NodeList[interalIterator].LoadPortID == p.LoadPorts)
                  {
                      Console.WriteLine(threadid + "  : " + 
                          "Entered operation for LP:" + 
                          p.LoadPorts.ToString());
                      SetNextEnum(coll, interalIterator);
                      coll.processcompleted.Set();
                  }
              }
          }
          Console.WriteLine(threadid + "  : " + "Loop End");
          Thread.Sleep(1500);
      }
  }
  </code></pre>