<?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_by_API%2FSystem.Threading%2FThread</id>
		<title>Csharp/C Sharp by API/System.Threading/Thread - История изменений</title>
		<link rel="self" type="application/atom+xml" href="http://nfex.ru/index.php?action=history&amp;feed=atom&amp;title=Csharp%2FC_Sharp_by_API%2FSystem.Threading%2FThread"/>
		<link rel="alternate" type="text/html" href="http://nfex.ru/index.php?title=Csharp/C_Sharp_by_API/System.Threading/Thread&amp;action=history"/>
		<updated>2026-04-29T21:31:38Z</updated>
		<subtitle>История изменений этой страницы в вики</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>http://nfex.ru/index.php?title=Csharp/C_Sharp_by_API/System.Threading/Thread&amp;diff=4012&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_by_API/System.Threading/Thread&amp;diff=4012&amp;oldid=prev"/>
				<updated>2010-05-26T15:31:35Z</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_by_API/System.Threading/Thread&amp;diff=4013&amp;oldid=prev</id>
		<title>Admin: 1 версия</title>
		<link rel="alternate" type="text/html" href="http://nfex.ru/index.php?title=Csharp/C_Sharp_by_API/System.Threading/Thread&amp;diff=4013&amp;oldid=prev"/>
				<updated>2010-05-26T12:08:52Z</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;==new Thread()==&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;
using System;&lt;br /&gt;
using System.Collections.Generic;&lt;br /&gt;
using System.Diagnostics;&lt;br /&gt;
using System.IO;&lt;br /&gt;
using System.Reflection;&lt;br /&gt;
using System.Runtime;&lt;br /&gt;
using System.Threading;&lt;br /&gt;
using System.Runtime.rupilerServices;&lt;br /&gt;
using System.Security;&lt;br /&gt;
using System.Text;&lt;br /&gt;
public class MainClass&lt;br /&gt;
{&lt;br /&gt;
    public static void Main()&lt;br /&gt;
    {&lt;br /&gt;
        Thread paramThread = new Thread(ParameterizedWorkerOperation);&lt;br /&gt;
        paramThread.Start(&amp;quot;Test&amp;quot;);&lt;br /&gt;
        paramThread.Join();&lt;br /&gt;
    }&lt;br /&gt;
    private static void ParameterizedWorkerOperation(object o)&lt;br /&gt;
    {&lt;br /&gt;
        Console.WriteLine(&amp;quot;Param worker: {0}&amp;quot;, o);&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.Abort()==&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;
using System;&lt;br /&gt;
using System.Threading;&lt;br /&gt;
class MainClass&lt;br /&gt;
{&lt;br /&gt;
  static int MyCount = 0;&lt;br /&gt;
  static void Main(string[] args)&lt;br /&gt;
  {&lt;br /&gt;
    MyClassThread me = new MyClassThread();&lt;br /&gt;
    Thread MyNewThread = new Thread(new ThreadStart(me.MyThread));&lt;br /&gt;
    MyNewThread.Start();&lt;br /&gt;
    if (MyCount == 0)&lt;br /&gt;
      MyNewThread.Abort();&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
class MyClassThread&lt;br /&gt;
{&lt;br /&gt;
  public void MyThread()&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.AllocateDataSlot==&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;
using System;&lt;br /&gt;
using System.Collections.Generic;&lt;br /&gt;
using System.Diagnostics;&lt;br /&gt;
using System.IO;&lt;br /&gt;
using System.Reflection;&lt;br /&gt;
using System.Runtime;&lt;br /&gt;
using System.Runtime.rupilerServices;&lt;br /&gt;
using System.Security;&lt;br /&gt;
using System.Text;&lt;br /&gt;
using System.Threading;&lt;br /&gt;
public class MainClass&lt;br /&gt;
{&lt;br /&gt;
    public static void Main()&lt;br /&gt;
    {&lt;br /&gt;
        LocalDataStoreSlot slot = Thread.AllocateDataSlot();&lt;br /&gt;
        Thread.SetData(slot, 63);&lt;br /&gt;
        int slotValue1 = (int)Thread.GetData(slot);&lt;br /&gt;
        Console.WriteLine(slotValue1);&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.AllocateNamedDataSlot==&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;
using System;&lt;br /&gt;
using System.Collections.Generic;&lt;br /&gt;
using System.Diagnostics;&lt;br /&gt;
using System.IO;&lt;br /&gt;
using System.Reflection;&lt;br /&gt;
using System.Runtime;&lt;br /&gt;
using System.Runtime.rupilerServices;&lt;br /&gt;
using System.Security;&lt;br /&gt;
using System.Text;&lt;br /&gt;
using System.Threading;&lt;br /&gt;
&lt;br /&gt;
public class MainClass&lt;br /&gt;
{&lt;br /&gt;
    public static void Main()&lt;br /&gt;
    {&lt;br /&gt;
        Thread.SetData(Thread.AllocateNamedDataSlot(&amp;quot;TestSlot&amp;quot;), 126);&lt;br /&gt;
        int slotValue2 = (int)Thread.GetData(Thread.GetNamedDataSlot(&amp;quot;TestSlot&amp;quot;));&lt;br /&gt;
        Console.WriteLine(slotValue2);&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.CurrentContext==&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 Program {&lt;br /&gt;
    static void Main(string[] args) {&lt;br /&gt;
        Thread primaryThread = Thread.CurrentThread;&lt;br /&gt;
        primaryThread.Name = &amp;quot;ThePrimaryThread&amp;quot;;&lt;br /&gt;
        Console.WriteLine(&amp;quot;Name of current AppDomain: {0}&amp;quot;, Thread.GetDomain().FriendlyName);&lt;br /&gt;
        Console.WriteLine(&amp;quot;ID of current Context: {0}&amp;quot;, Thread.CurrentContext.ContextID);&lt;br /&gt;
        Console.WriteLine(&amp;quot;Thread Name: {0}&amp;quot;, primaryThread.Name);&lt;br /&gt;
        Console.WriteLine(&amp;quot;Has thread started?: {0}&amp;quot;, primaryThread.IsAlive);&lt;br /&gt;
        Console.WriteLine(&amp;quot;Priority Level: {0}&amp;quot;, primaryThread.Priority);&lt;br /&gt;
        Console.WriteLine(&amp;quot;Thread State: {0}&amp;quot;, primaryThread.ThreadState);&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.CurrentCulture==&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;
using System;&lt;br /&gt;
using System.Globalization;&lt;br /&gt;
using System.Threading;&lt;br /&gt;
class MainClass&lt;br /&gt;
{&lt;br /&gt;
  public static void Main() &lt;br /&gt;
  {&lt;br /&gt;
    Console.WriteLine(Thread.CurrentThread.CurrentCulture.Name);&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.CurrentThread==&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.Globalization;&lt;br /&gt;
using System.Threading;&lt;br /&gt;
class MainClass&lt;br /&gt;
{&lt;br /&gt;
  public static void Main() &lt;br /&gt;
  {&lt;br /&gt;
    Thread.CurrentThread.CurrentCulture=new CultureInfo(&amp;quot;de-DE&amp;quot;);&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.GetData==&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;
using System;&lt;br /&gt;
using System.Collections.Generic;&lt;br /&gt;
using System.Diagnostics;&lt;br /&gt;
using System.IO;&lt;br /&gt;
using System.Reflection;&lt;br /&gt;
using System.Runtime;&lt;br /&gt;
using System.Runtime.rupilerServices;&lt;br /&gt;
using System.Security;&lt;br /&gt;
using System.Threading;&lt;br /&gt;
using System.Text;&lt;br /&gt;
public class MainClass&lt;br /&gt;
{&lt;br /&gt;
    public static void Main()&lt;br /&gt;
    {&lt;br /&gt;
        LocalDataStoreSlot slot = Thread.AllocateDataSlot();&lt;br /&gt;
        Thread.SetData(slot, 63);&lt;br /&gt;
        int slotValue1 = (int)Thread.GetData(slot);&lt;br /&gt;
        Console.WriteLine(slotValue1);&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.GetHashCode()==&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;
&lt;br /&gt;
using System;&lt;br /&gt;
using System.Collections.Generic;&lt;br /&gt;
using System.Text;&lt;br /&gt;
using System.Threading;&lt;br /&gt;
class AddParams {&lt;br /&gt;
    public int a;&lt;br /&gt;
    public int b;&lt;br /&gt;
    public AddParams(int numb1, int numb2) {&lt;br /&gt;
        a = numb1;&lt;br /&gt;
        b = numb2;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
class Program {&lt;br /&gt;
    public static void Add(object data) {&lt;br /&gt;
        if (data is AddParams) {&lt;br /&gt;
            Console.WriteLine(&amp;quot;ID of thread in Add(): {0}&amp;quot;,Thread.CurrentThread.GetHashCode());&lt;br /&gt;
            AddParams ap = (AddParams)data;&lt;br /&gt;
            Console.WriteLine(&amp;quot;{0} + {1} is {2}&amp;quot;, ap.a, ap.b, ap.a + ap.b);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    static void Main(string[] args) {&lt;br /&gt;
        Console.WriteLine(&amp;quot;ID of thread in Main(): {0}&amp;quot;, Thread.CurrentThread.GetHashCode());&lt;br /&gt;
        AddParams ap = new AddParams(10, 10);&lt;br /&gt;
        Thread t = new Thread(new ParameterizedThreadStart(Add));&lt;br /&gt;
        t.Start(ap);&lt;br /&gt;
        Console.ReadLine();&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.Interrupt()==&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;
using System;&lt;br /&gt;
using System.Drawing;&lt;br /&gt;
using System.Collections;&lt;br /&gt;
using System.ruponentModel;&lt;br /&gt;
using System.Windows.Forms;&lt;br /&gt;
using System.Data;&lt;br /&gt;
using System.Threading;&lt;br /&gt;
public class Form1 : System.Windows.Forms.Form {&lt;br /&gt;
    private System.Windows.Forms.ProgressBar progressBar1;&lt;br /&gt;
    private System.Windows.Forms.Button button1;&lt;br /&gt;
    private System.Windows.Forms.Button button2;&lt;br /&gt;
    private Thread fThread = null;&lt;br /&gt;
    private System.ruponentModel.Container components = null;&lt;br /&gt;
    public Form1() {&lt;br /&gt;
        this.progressBar1 = new System.Windows.Forms.ProgressBar();&lt;br /&gt;
        this.button1 = new System.Windows.Forms.Button();&lt;br /&gt;
        this.button2 = new System.Windows.Forms.Button();&lt;br /&gt;
        this.SuspendLayout();&lt;br /&gt;
        this.progressBar1.Location = new System.Drawing.Point(24, 32);&lt;br /&gt;
        this.progressBar1.Name = &amp;quot;progressBar1&amp;quot;;&lt;br /&gt;
        this.progressBar1.Size = new System.Drawing.Size(264, 23);&lt;br /&gt;
        this.progressBar1.TabIndex = 0;&lt;br /&gt;
        this.button1.Location = new System.Drawing.Point(24, 80);&lt;br /&gt;
        this.button1.Size = new System.Drawing.Size(136, 40);&lt;br /&gt;
        this.button1.Text = &amp;quot;Start Thread&amp;quot;;&lt;br /&gt;
        this.button1.Click += new&lt;br /&gt;
             System.EventHandler(this.button1_Click);&lt;br /&gt;
        this.button2.Location = new System.Drawing.Point(168, 80);&lt;br /&gt;
        this.button2.Size = new System.Drawing.Size(120, 40);&lt;br /&gt;
        this.button2.Text = &amp;quot;Stop Thread&amp;quot;;&lt;br /&gt;
        this.button2.Click += new&lt;br /&gt;
             System.EventHandler(this.button2_Click);&lt;br /&gt;
        this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);&lt;br /&gt;
        this.ClientSize = new System.Drawing.Size(704, 429);&lt;br /&gt;
        this.Controls.AddRange(new System.Windows.Forms.Control[] {&lt;br /&gt;
          this.button2,&lt;br /&gt;
          this.button1,&lt;br /&gt;
          this.progressBar1});&lt;br /&gt;
        this.ResumeLayout(false);&lt;br /&gt;
    }&lt;br /&gt;
    protected override void Dispose(bool disposing) {&lt;br /&gt;
        if (fThread != null) {&lt;br /&gt;
            fThread.Interrupt();&lt;br /&gt;
            fThread = null;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    [STAThread]&lt;br /&gt;
    static void Main() {&lt;br /&gt;
        Application.Run(new Form1());&lt;br /&gt;
    }&lt;br /&gt;
    private void UpdateProgress() {&lt;br /&gt;
        if (progressBar1.Value == progressBar1.Maximum) {&lt;br /&gt;
            progressBar1.Value = progressBar1.Minimum;&lt;br /&gt;
        }&lt;br /&gt;
        progressBar1.PerformStep();&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    public void ThreadProc() {&lt;br /&gt;
        try {&lt;br /&gt;
            MethodInvoker mi = new MethodInvoker(this.UpdateProgress);&lt;br /&gt;
            while (true) {&lt;br /&gt;
                this.BeginInvoke(mi);&lt;br /&gt;
                Thread.Sleep(500);&lt;br /&gt;
            }&lt;br /&gt;
        } catch (ThreadInterruptedException e) {&lt;br /&gt;
            Console.WriteLine(&lt;br /&gt;
              &amp;quot;Interruption Exception in Thread: {0}&amp;quot;,&lt;br /&gt;
                  e);&lt;br /&gt;
        } catch (Exception we) {&lt;br /&gt;
            Console.WriteLine(&amp;quot;Exception in Thread: {0}&amp;quot;, we);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    private void button1_Click(object sender, System.EventArgs e) {&lt;br /&gt;
        fThread = new Thread(new ThreadStart(ThreadProc));&lt;br /&gt;
        fThread.IsBackground = true;&lt;br /&gt;
        fThread.Start();&lt;br /&gt;
    }&lt;br /&gt;
    private void button2_Click(object sender, System.EventArgs e) {&lt;br /&gt;
        fThread.Interrupt();&lt;br /&gt;
        fThread = null;&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.IsAlive==&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;
using System;&lt;br /&gt;
using System.Threading;&lt;br /&gt;
public class ThreadState {&lt;br /&gt;
    static void WorkerFunction() {&lt;br /&gt;
        for (int i = 1; i &amp;lt; 50000; i++) {&lt;br /&gt;
            Console.WriteLine(&amp;quot;Worker: &amp;quot; + Thread.CurrentThread.ThreadState);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    static void Main() {&lt;br /&gt;
        string ThreadState;&lt;br /&gt;
        Thread t = new Thread(new ThreadStart(WorkerFunction));&lt;br /&gt;
        t.Start();&lt;br /&gt;
        while (t.IsAlive) {&lt;br /&gt;
            Console.WriteLine(&amp;quot;Still waiting. I&amp;quot;m going back to sleep.&amp;quot;);&lt;br /&gt;
            Thread.Sleep(200);&lt;br /&gt;
        }&lt;br /&gt;
        Console.WriteLine(t.ThreadState);&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.IsBackground==&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;
using System;&lt;br /&gt;
using System.Drawing;&lt;br /&gt;
using System.Collections;&lt;br /&gt;
using System.ruponentModel;&lt;br /&gt;
using System.Windows.Forms;&lt;br /&gt;
using System.Data;&lt;br /&gt;
using System.Threading;&lt;br /&gt;
public class Form1 : System.Windows.Forms.Form {&lt;br /&gt;
    private System.Windows.Forms.ProgressBar progressBar1;&lt;br /&gt;
    private System.Windows.Forms.Button button1;&lt;br /&gt;
    private System.Windows.Forms.Button button2;&lt;br /&gt;
    private Thread fThread = null;&lt;br /&gt;
    private System.ruponentModel.Container components = null;&lt;br /&gt;
    public Form1() {&lt;br /&gt;
        this.progressBar1 = new System.Windows.Forms.ProgressBar();&lt;br /&gt;
        this.button1 = new System.Windows.Forms.Button();&lt;br /&gt;
        this.button2 = new System.Windows.Forms.Button();&lt;br /&gt;
        this.SuspendLayout();&lt;br /&gt;
        this.progressBar1.Location = new System.Drawing.Point(24, 32);&lt;br /&gt;
        this.progressBar1.Name = &amp;quot;progressBar1&amp;quot;;&lt;br /&gt;
        this.progressBar1.Size = new System.Drawing.Size(264, 23);&lt;br /&gt;
        this.progressBar1.TabIndex = 0;&lt;br /&gt;
        this.button1.Location = new System.Drawing.Point(24, 80);&lt;br /&gt;
        this.button1.Size = new System.Drawing.Size(136, 40);&lt;br /&gt;
        this.button1.Text = &amp;quot;Start Thread&amp;quot;;&lt;br /&gt;
        this.button1.Click += new&lt;br /&gt;
             System.EventHandler(this.button1_Click);&lt;br /&gt;
        this.button2.Location = new System.Drawing.Point(168, 80);&lt;br /&gt;
        this.button2.Size = new System.Drawing.Size(120, 40);&lt;br /&gt;
        this.button2.Text = &amp;quot;Stop Thread&amp;quot;;&lt;br /&gt;
        this.button2.Click += new&lt;br /&gt;
             System.EventHandler(this.button2_Click);&lt;br /&gt;
        this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);&lt;br /&gt;
        this.ClientSize = new System.Drawing.Size(704, 429);&lt;br /&gt;
        this.Controls.AddRange(new System.Windows.Forms.Control[] {&lt;br /&gt;
          this.button2,&lt;br /&gt;
          this.button1,&lt;br /&gt;
          this.progressBar1});&lt;br /&gt;
        this.ResumeLayout(false);&lt;br /&gt;
    }&lt;br /&gt;
    protected override void Dispose(bool disposing) {&lt;br /&gt;
        if (fThread != null) {&lt;br /&gt;
            fThread.Interrupt();&lt;br /&gt;
            fThread = null;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    [STAThread]&lt;br /&gt;
    static void Main() {&lt;br /&gt;
        Application.Run(new Form1());&lt;br /&gt;
    }&lt;br /&gt;
    private void UpdateProgress() {&lt;br /&gt;
        if (progressBar1.Value == progressBar1.Maximum) {&lt;br /&gt;
            progressBar1.Value = progressBar1.Minimum;&lt;br /&gt;
        }&lt;br /&gt;
        progressBar1.PerformStep();&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    public void ThreadProc() {&lt;br /&gt;
        try {&lt;br /&gt;
            MethodInvoker mi = new MethodInvoker(this.UpdateProgress);&lt;br /&gt;
            while (true) {&lt;br /&gt;
                this.BeginInvoke(mi);&lt;br /&gt;
                Thread.Sleep(500);&lt;br /&gt;
            }&lt;br /&gt;
        } catch (ThreadInterruptedException e) {&lt;br /&gt;
            Console.WriteLine(&lt;br /&gt;
              &amp;quot;Interruption Exception in Thread: {0}&amp;quot;,&lt;br /&gt;
                  e);&lt;br /&gt;
        } catch (Exception we) {&lt;br /&gt;
            Console.WriteLine(&amp;quot;Exception in Thread: {0}&amp;quot;, we);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    private void button1_Click(object sender, System.EventArgs e) {&lt;br /&gt;
        fThread = new Thread(new ThreadStart(ThreadProc));&lt;br /&gt;
        fThread.IsBackground = true;&lt;br /&gt;
        fThread.Start();&lt;br /&gt;
    }&lt;br /&gt;
    private void button2_Click(object sender, System.EventArgs e) {&lt;br /&gt;
        fThread.Interrupt();&lt;br /&gt;
        fThread = null;&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.Join()==&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;
using System;&lt;br /&gt;
using System.Threading;&lt;br /&gt;
   &lt;br /&gt;
class Sum {&lt;br /&gt;
    public Sum(int op1, int op2) {&lt;br /&gt;
        Console.WriteLine(&amp;quot;[Sum.Sum] Instantiated with values of {0} and {1}&amp;quot;, op1, op2);&lt;br /&gt;
        this.op1 = op1;&lt;br /&gt;
        this.op2 = op2;&lt;br /&gt;
    }&lt;br /&gt;
    int op1;&lt;br /&gt;
    int op2;&lt;br /&gt;
    int result;&lt;br /&gt;
    public int Result{ get { return result; } }&lt;br /&gt;
   &lt;br /&gt;
    public void Add()&lt;br /&gt;
    {&lt;br /&gt;
        Thread.Sleep(5000);&lt;br /&gt;
        result = op1 + op2;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
class ThreadData {&lt;br /&gt;
    static void Main() {&lt;br /&gt;
        Sum sum = new Sum(6, 42);&lt;br /&gt;
   &lt;br /&gt;
        Thread thread = new Thread(new ThreadStart(sum.Add));&lt;br /&gt;
        thread.Start();&lt;br /&gt;
   &lt;br /&gt;
        for (int i = 0; i &amp;lt; 10; i++) {&lt;br /&gt;
            Thread.Sleep(200);&lt;br /&gt;
            Console.Write(&amp;quot;.&amp;quot;);&lt;br /&gt;
        }&lt;br /&gt;
        thread.Join();&lt;br /&gt;
   &lt;br /&gt;
        Console.WriteLine(&amp;quot;[Main] The result is {0}&amp;quot;, sum.Result);&lt;br /&gt;
        Console.ReadLine();&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.ResetAbort()==&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;
using System; &lt;br /&gt;
using System.Threading; &lt;br /&gt;
 &lt;br /&gt;
class MyThread {  &lt;br /&gt;
  public Thread thrd;  &lt;br /&gt;
    &lt;br /&gt;
  public MyThread(string name) {  &lt;br /&gt;
    thrd = new Thread(this.run); &lt;br /&gt;
    thrd.Name = name; &lt;br /&gt;
    thrd.Start();  &lt;br /&gt;
  }  &lt;br /&gt;
  &lt;br /&gt;
  void run() {  &lt;br /&gt;
    Console.WriteLine(thrd.Name + &amp;quot; starting.&amp;quot;); &lt;br /&gt;
 &lt;br /&gt;
    for(int i = 1; i &amp;lt;= 100; i++) {  &lt;br /&gt;
      try { &lt;br /&gt;
        Console.Write(i + &amp;quot; &amp;quot;);  &lt;br /&gt;
        Thread.Sleep(50); &lt;br /&gt;
      } catch(ThreadAbortException exc) { &lt;br /&gt;
        if((int)exc.ExceptionState == 0) { &lt;br /&gt;
          Console.WriteLine(&amp;quot;Abort Cancelled! Code is &amp;quot; + exc.ExceptionState); &lt;br /&gt;
          Thread.ResetAbort(); &lt;br /&gt;
        } else  &lt;br /&gt;
          Console.WriteLine(&amp;quot;Thread aborting, code is &amp;quot; + exc.ExceptionState); &lt;br /&gt;
      } &lt;br /&gt;
    } &lt;br /&gt;
    Console.WriteLine(thrd.Name + &amp;quot; exiting normally.&amp;quot;);  &lt;br /&gt;
  } &lt;br /&gt;
} &lt;br /&gt;
  &lt;br /&gt;
class MainClass {  &lt;br /&gt;
  public static void Main() {  &lt;br /&gt;
    MyThread mt1 = new MyThread(&amp;quot;My Thread&amp;quot;);  &lt;br /&gt;
 &lt;br /&gt;
    Thread.Sleep(1000); &lt;br /&gt;
 &lt;br /&gt;
    Console.WriteLine(&amp;quot;Stopping thread.&amp;quot;);  &lt;br /&gt;
    mt1.thrd.Abort(100); &lt;br /&gt;
 &lt;br /&gt;
    mt1.thrd.Join(); &lt;br /&gt;
 &lt;br /&gt;
    Console.WriteLine(&amp;quot;Main thread terminating.&amp;quot;);  &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.SetData==&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;
using System;&lt;br /&gt;
using System.Collections.Generic;&lt;br /&gt;
using System.Diagnostics;&lt;br /&gt;
using System.IO;&lt;br /&gt;
using System.Reflection;&lt;br /&gt;
using System.Runtime;&lt;br /&gt;
using System.Runtime.rupilerServices;&lt;br /&gt;
using System.Security;&lt;br /&gt;
using System.Text;&lt;br /&gt;
using System.Threading;&lt;br /&gt;
public class MainClass&lt;br /&gt;
{&lt;br /&gt;
    public static void Main()&lt;br /&gt;
    {&lt;br /&gt;
        LocalDataStoreSlot slot = Thread.AllocateDataSlot();&lt;br /&gt;
        Thread.SetData(slot, 63);&lt;br /&gt;
        int slotValue1 = (int)Thread.GetData(slot);&lt;br /&gt;
        Console.WriteLine(slotValue1);&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.Sleep==&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;
 &lt;br /&gt;
using System; &lt;br /&gt;
using System.Threading; &lt;br /&gt;
 &lt;br /&gt;
class MyThread { &lt;br /&gt;
  public int count; &lt;br /&gt;
  public Thread thrd; &lt;br /&gt;
 &lt;br /&gt;
  public MyThread(string name) { &lt;br /&gt;
    count = 0; &lt;br /&gt;
    thrd = new Thread(this.run); &lt;br /&gt;
    thrd.Name = name; &lt;br /&gt;
    thrd.Start(); &lt;br /&gt;
  } &lt;br /&gt;
 &lt;br /&gt;
  void run() { &lt;br /&gt;
    Console.WriteLine(thrd.Name + &amp;quot; starting.&amp;quot;); &lt;br /&gt;
 &lt;br /&gt;
    do { &lt;br /&gt;
      Thread.Sleep(500); &lt;br /&gt;
      Console.WriteLine(&amp;quot;In &amp;quot; + thrd.Name + &lt;br /&gt;
                        &amp;quot;, count is &amp;quot; + count); &lt;br /&gt;
      count++; &lt;br /&gt;
    } while(count &amp;lt; 10); &lt;br /&gt;
 &lt;br /&gt;
    Console.WriteLine(thrd.Name + &amp;quot; terminating.&amp;quot;); &lt;br /&gt;
  } &lt;br /&gt;
} &lt;br /&gt;
 &lt;br /&gt;
class MainClass { &lt;br /&gt;
  public static void Main() { &lt;br /&gt;
    Console.WriteLine(&amp;quot;Main thread starting.&amp;quot;); &lt;br /&gt;
 &lt;br /&gt;
    MyThread mt1 = new MyThread(&amp;quot;Child #1&amp;quot;); &lt;br /&gt;
    MyThread mt2 = new MyThread(&amp;quot;Child #2&amp;quot;); &lt;br /&gt;
    MyThread mt3 = new MyThread(&amp;quot;Child #3&amp;quot;); &lt;br /&gt;
 &lt;br /&gt;
    Thread.Sleep(10000); &lt;br /&gt;
 &lt;br /&gt;
    Console.WriteLine(&amp;quot;Main thread ending.&amp;quot;); &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.ThreadState==&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;
using System;&lt;br /&gt;
using System.Threading;&lt;br /&gt;
class MainClass&lt;br /&gt;
{&lt;br /&gt;
  static void MyThreadProc()&lt;br /&gt;
  {&lt;br /&gt;
    Thread.CurrentThread.Name = &amp;quot;TheSecondaryThread&amp;quot;;&lt;br /&gt;
    Thread secondaryThread = Thread.CurrentThread;&lt;br /&gt;
    Console.WriteLine(&amp;quot;Name? {0}&amp;quot;, secondaryThread.Name);&lt;br /&gt;
    Console.WriteLine(&amp;quot;Alive? {0}&amp;quot;, secondaryThread.IsAlive);&lt;br /&gt;
    Console.WriteLine(&amp;quot;Priority? {0}&amp;quot;, secondaryThread.Priority);      &lt;br /&gt;
    Console.WriteLine(&amp;quot;State? {0}&amp;quot;, secondaryThread.ThreadState);&lt;br /&gt;
    Console.WriteLine();&lt;br /&gt;
    for(int i = 0; i &amp;lt; 1000; i ++)&lt;br /&gt;
    {&lt;br /&gt;
      Console.WriteLine(&amp;quot;Value of i is: {0}&amp;quot;, i);&lt;br /&gt;
      Thread.Sleep(5);&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  [MTAThread]&lt;br /&gt;
  static void Main(string[] args)&lt;br /&gt;
  {&lt;br /&gt;
    Thread secondaryThread = new Thread(new ThreadStart(MyThreadProc));&lt;br /&gt;
    secondaryThread.Priority = ThreadPriority.Highest;&lt;br /&gt;
    &lt;br /&gt;
    secondaryThread.IsBackground = true;&lt;br /&gt;
    secondaryThread.Start();&lt;br /&gt;
  }&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>