<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ru">
		<id>http://nfex.ru/index.php?action=history&amp;feed=atom&amp;title=Csharp%2FC_Sharp%2FThread%2FThread_Start_Wait</id>
		<title>Csharp/C Sharp/Thread/Thread Start Wait - История изменений</title>
		<link rel="self" type="application/atom+xml" href="http://nfex.ru/index.php?action=history&amp;feed=atom&amp;title=Csharp%2FC_Sharp%2FThread%2FThread_Start_Wait"/>
		<link rel="alternate" type="text/html" href="http://nfex.ru/index.php?title=Csharp/C_Sharp/Thread/Thread_Start_Wait&amp;action=history"/>
		<updated>2026-04-29T23:13:07Z</updated>
		<subtitle>История изменений этой страницы в вики</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>http://nfex.ru/index.php?title=Csharp/C_Sharp/Thread/Thread_Start_Wait&amp;diff=1079&amp;oldid=prev</id>
		<title> в 15:31, 26 мая 2010</title>
		<link rel="alternate" type="text/html" href="http://nfex.ru/index.php?title=Csharp/C_Sharp/Thread/Thread_Start_Wait&amp;diff=1079&amp;oldid=prev"/>
				<updated>2010-05-26T15:31:19Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr style=&quot;vertical-align: top;&quot; lang=&quot;ru&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Предыдущая&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Версия 15:31, 26 мая 2010&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; style=&quot;text-align: center;&quot; lang=&quot;ru&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(нет различий)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
			</entry>

	<entry>
		<id>http://nfex.ru/index.php?title=Csharp/C_Sharp/Thread/Thread_Start_Wait&amp;diff=1080&amp;oldid=prev</id>
		<title>Admin: 1 версия</title>
		<link rel="alternate" type="text/html" href="http://nfex.ru/index.php?title=Csharp/C_Sharp/Thread/Thread_Start_Wait&amp;diff=1080&amp;oldid=prev"/>
				<updated>2010-05-26T11:42:58Z</updated>
		
		<summary type="html">&lt;p&gt;1 версия&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Новая страница&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==Demonstates starting and waiting on a thread==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
C# Programming Tips &amp;amp; Techniques&lt;br /&gt;
by Charles Wright, Kris Jamsa&lt;br /&gt;
Publisher: Osborne/McGraw-Hill (December 28, 2001)&lt;br /&gt;
ISBN: 0072193794&lt;br /&gt;
*/&lt;br /&gt;
// Thread.cs -- Demonstates starting and waiting on a thread&lt;br /&gt;
//&lt;br /&gt;
//              Compile this program with the following command line:&lt;br /&gt;
//                  C:&amp;gt;csc Thread.cs&lt;br /&gt;
using System;&lt;br /&gt;
using System.Windows.Forms;&lt;br /&gt;
using System.Threading;&lt;br /&gt;
namespace nsThreads&lt;br /&gt;
{&lt;br /&gt;
    public class ThreadDemo&lt;br /&gt;
    {&lt;br /&gt;
        static public void Main ()&lt;br /&gt;
        {&lt;br /&gt;
// Create the new thread object&lt;br /&gt;
            Thread NewThread = new Thread (new ThreadStart (RunThread));&lt;br /&gt;
// Show a message box.&lt;br /&gt;
            MessageBox.Show (&amp;quot;Click OK to start the thread&amp;quot;, &amp;quot;Thread Start&amp;quot;);&lt;br /&gt;
// Start the new thread.&lt;br /&gt;
            NewThread.Start ();&lt;br /&gt;
// Inform everybody that the main thread is waiting&lt;br /&gt;
            Console.WriteLine (&amp;quot;Waiting . . .&amp;quot;);&lt;br /&gt;
// Wait for NewThread to terminate.&lt;br /&gt;
            NewThread.Join ();&lt;br /&gt;
// And it&amp;quot;s done.&lt;br /&gt;
            Console.WriteLine (&amp;quot;\r\nDone . . .&amp;quot;);&lt;br /&gt;
        }&lt;br /&gt;
// Method to assign to the new thread as its start method&lt;br /&gt;
        static public void RunThread ()&lt;br /&gt;
        {&lt;br /&gt;
// Sleep for a second, print and message and repeat.&lt;br /&gt;
            for (int x = 5; x &amp;gt; 0; --x)&lt;br /&gt;
            {&lt;br /&gt;
                Thread.Sleep (1000);&lt;br /&gt;
                Console.Write (&amp;quot;Thread is running. {0} second{1}  \r&amp;quot;,&lt;br /&gt;
                               x, x &amp;gt; 1 ? &amp;quot;s&amp;quot; : &amp;quot;&amp;quot;);&lt;br /&gt;
            }&lt;br /&gt;
// The thread will terminate at this point. It will not return to&lt;br /&gt;
// the method that started it.&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Thread Sample==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
C# Network Programming &lt;br /&gt;
by Richard Blum&lt;br /&gt;
Publisher: Sybex &lt;br /&gt;
ISBN: 0782141765&lt;br /&gt;
*/&lt;br /&gt;
using System;&lt;br /&gt;
using System.Threading;&lt;br /&gt;
public class ThreadSample&lt;br /&gt;
{&lt;br /&gt;
   public static void Main()&lt;br /&gt;
   {&lt;br /&gt;
      ThreadSample ts = new ThreadSample();&lt;br /&gt;
   }&lt;br /&gt;
   public ThreadSample()&lt;br /&gt;
   {&lt;br /&gt;
      int i;&lt;br /&gt;
      Thread newCounter = new Thread(new ThreadStart(Counter));&lt;br /&gt;
      Thread newCounter2 = new Thread(new ThreadStart(Counter2));&lt;br /&gt;
      newCounter.Start();&lt;br /&gt;
      newCounter2.Start();&lt;br /&gt;
      for(i = 0; i &amp;lt; 10; i++)&lt;br /&gt;
      {&lt;br /&gt;
         Console.WriteLine(&amp;quot;main: {0}&amp;quot;, i);&lt;br /&gt;
         Thread.Sleep(1000);&lt;br /&gt;
      }&lt;br /&gt;
   }&lt;br /&gt;
   void Counter()&lt;br /&gt;
   {&lt;br /&gt;
      int i;&lt;br /&gt;
      for (i = 0; i &amp;lt; 10; i++)&lt;br /&gt;
      {&lt;br /&gt;
         Console.WriteLine(&amp;quot;  thread: {0}&amp;quot;, i);&lt;br /&gt;
         Thread.Sleep(2000);&lt;br /&gt;
      }&lt;br /&gt;
   }&lt;br /&gt;
   void Counter2()&lt;br /&gt;
   {&lt;br /&gt;
      int i;&lt;br /&gt;
      for (i = 0; i &amp;lt; 10; i++)&lt;br /&gt;
      {&lt;br /&gt;
         Console.WriteLine(&amp;quot;    thread2: {0}&amp;quot;, i);&lt;br /&gt;
         Thread.Sleep(3000);&lt;br /&gt;
      }&lt;br /&gt;
   }&lt;br /&gt;
}&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Threads:Waiting with WaitHandle==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
using System;&lt;br /&gt;
using System.Threading;&lt;br /&gt;
class ThreadSleeper&lt;br /&gt;
{&lt;br /&gt;
    int seconds;&lt;br /&gt;
    AutoResetEvent napDone = new AutoResetEvent(false);&lt;br /&gt;
    &lt;br /&gt;
    private ThreadSleeper(int seconds)&lt;br /&gt;
    {&lt;br /&gt;
        this.seconds = seconds; &lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    public void Nap()&lt;br /&gt;
    {&lt;br /&gt;
        Console.WriteLine(&amp;quot;Napping {0} seconds&amp;quot;, seconds);&lt;br /&gt;
        Thread.Sleep(seconds * 1000);&lt;br /&gt;
        Console.WriteLine(&amp;quot;{0} second nap finished&amp;quot;, seconds);&lt;br /&gt;
        napDone.Set();&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    public static WaitHandle DoSleep(int seconds)&lt;br /&gt;
    {&lt;br /&gt;
        ThreadSleeper ts = new ThreadSleeper(seconds);&lt;br /&gt;
        Thread thread = new Thread(new ThreadStart(ts.Nap));&lt;br /&gt;
        thread.Start();&lt;br /&gt;
        return(ts.napDone);&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
public class OperationsThreadsWaitingwithWaitHandle&lt;br /&gt;
{&lt;br /&gt;
    public static void Main()&lt;br /&gt;
    {&lt;br /&gt;
        WaitHandle[] waits = new WaitHandle[2];&lt;br /&gt;
        waits[0] = ThreadSleeper.DoSleep(8);&lt;br /&gt;
        waits[1] = ThreadSleeper.DoSleep(4);&lt;br /&gt;
        &lt;br /&gt;
        Console.WriteLine(&amp;quot;Waiting for threads to finish&amp;quot;);&lt;br /&gt;
        WaitHandle.WaitAll(waits);&lt;br /&gt;
        Console.WriteLine(&amp;quot;Threads finished&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	</feed>