Demonstates starting and waiting on a thread : Thread Start Wait « Thread « C# / C Sharp

C# / C Sharp
1. 2D Graphics
2. Class Interface
3. Collections Data Structure
4. Components
5. Data Types
6. Database ADO.net
7. Design Patterns
8. Development Class
9. Event
10. File Stream
11. Generics
12. GUI Windows Form
13. Language Basics
14. LINQ
15. Network
16. Office
17. Reflection
18. Regular Expressions
19. Security
20. Services Event
21. Thread
22. Web Services
23. Windows
24. XML
25. XML LINQ
Java
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
C# / CSharp Tutorial
ASP.Net
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
PHP
Python
SQL Server / T-SQL
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
C# / C Sharp » Thread » Thread Start WaitScreenshots 
Demonstates starting and waiting on a thread
Demonstates starting and waiting on a thread

/*
C# Programming Tips & Techniques
by Charles Wright, Kris Jamsa

Publisher: Osborne/McGraw-Hill (December 28, 2001)
ISBN: 0072193794
*/

// Thread.cs -- Demonstates starting and waiting on a thread
//
//              Compile this program with the following command line:
//                  C:>csc Thread.cs
using System;
using System.Windows.Forms;
using System.Threading;

namespace nsThreads
{
    public class ThreadDemo
    {
        static public void Main ()
        {
// Create the new thread object
            Thread NewThread = new Thread (new ThreadStart (RunThread));
// Show a message box.
            MessageBox.Show ("Click OK to start the thread""Thread Start");
// Start the new thread.
            NewThread.Start ();
// Inform everybody that the main thread is waiting
            Console.WriteLine ("Waiting . . .");
// Wait for NewThread to terminate.
            NewThread.Join ();
// And it's done.
            Console.WriteLine ("\r\nDone . . .");
        }

// Method to assign to the new thread as its start method
        static public void RunThread ()
        {
// Sleep for a second, print and message and repeat.
            for (int x = 5; x > 0; --x)
            {
                Thread.Sleep (1000);
                Console.Write ("Thread is running. {0} second{1}  \r",
                               x, x > "s" "");
            }
// The thread will terminate at this point. It will not return to
// the method that started it.
        }
    }
}


           
       
Related examples in the same category
1. Threads:Waiting with WaitHandleThreads:Waiting with WaitHandle
2. Thread SampleThread Sample
w___w_w.__ja___v___a_2__s__.___co___m___ | Contact Us
Copyright 2003 - 08 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.