none
multithread

    Question

  • i want a multithread examplw without console applicaton and how to use thread.sleep method program should be in c#.net
    • Moved by Larcolais Gong Monday, August 30, 2010 6:51 AM (From:.NET Framework Setup)
    Friday, August 27, 2010 4:38 AM

Answers

All replies

  • can't understand ex without console application. any way see the example below
    using System;
    using System.Threading;
    
    class Test
    {
      int waitTime = 1000;
    
      public static void Main() 
      {
        Thread newThread = new Thread(new ThreadStart(Work));
        newThread.Start();
        if(newThread.Join(waitTime + waitTime))
        {
          Console.WriteLine("New thread terminated.");
        }
        else
        {
          Console.WriteLine("Join timed out.");
        }
      }
    
      static void Work()
      {
        Thread.Sleep(waitTime);
      }
    }
    
    

     source: http://msdn.microsoft.com/en-us/library/system.threading.thread.sleep(VS.71).aspx


    Manish Sati
    Friday, August 27, 2010 4:49 AM
  • Hi mohittiwari,

    As your concern, it seems that your concerns might be related with C# development.

    I will moving this thread to C# General Forum.

    You will get more helpful suggestions there.

    Best Regards

    Larcolais Gong


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Monday, August 30, 2010 6:49 AM
  • Hi,

    What i suggest is to use

    using System.Threading;

    and use the below code where ever u want to have a thread...

    Thread newThread = new Thread(new ThreadStart(name of the procedure u want to run as thread);
    newThread.Start();

    The above code will start your thread procedure.

    You can have a look in the below for more details:

    http://msdn.microsoft.com/en-us/library/aa645740(VS.71).aspx

    Regards,

    John

    Monday, August 30, 2010 9:03 AM