Articles → .NET → Multithreading And Threadpool Basic Example

Multithreading And Threadpool Basic Example











  1. Create a separate thread
  2. Do some process using the thread.
  3. Destroy the thread.












  4. public void CreateFiles(object o) {
      for (int i = 1; i < 1000; i++) {
        // Create an XMLDocument instance        
        XmlDocument doc = new System.Xml.XmlDocument();
        // Load the Xml String into XmlDocument        
        doc.LoadXml("<Root></Root>");
        // Save the document        
        doc.Save("C:\\karan\\" + i.ToString() + ".xml");
      }
      MessageBox.Show("done");
    }


  5. Now on an event say button click call the function.
  6. bool status = ThreadPool.QueueUserWorkItem(new WaitCallback(CreateFiles));
    MessageBox.Show("karan");







Posted By  -  Karan Gupta
 
Posted On  -  Monday, August 30, 2010

Query/Feedback


Your Email Id  
 
Subject 
 
Query/FeedbackCharacters remaining 250