<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>eXclusiveMinds &#187; Threading</title>
	<atom:link href="http://eXclusiveMinds.com/tag/threading/feed/" rel="self" type="application/rss+xml" />
	<link>http://eXclusiveMinds.com</link>
	<description>eXclusive resource for programmers, developers and designers</description>
	<lastBuildDate>Sat, 13 Mar 2010 23:28:44 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Create New Thread in C#</title>
		<link>http://eXclusiveMinds.com/2009/12/02/create-new-thread-in-cshar/</link>
		<comments>http://eXclusiveMinds.com/2009/12/02/create-new-thread-in-cshar/#comments</comments>
		<pubDate>Tue, 01 Dec 2009 23:17:47 +0000</pubDate>
		<dc:creator>eXclusiveMinds</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Threading]]></category>

		<guid isPermaLink="false">http://eXclusiveMinds.com/?p=144</guid>
		<description><![CDATA[Following exampel demonstrates how can we create a new thread using C#.

i. Create aThreadStart delegate.
ii. Create instance of Thread by passing this delegate as a parameter.
iii.Call the Thread.Start method (i.e. WorkerFunction).

using System.Threading;
Thread newThread = new Thread&#40;new ThreadStart&#40;WorkerFunction&#41;&#41;;
newThread.Start&#40;&#41;;

The WorkerFunction could be defined as follows.

public void WorkerFunction&#40;&#41;
&#123;
  try
  &#123;
    // work
  [...]]]></description>
			<content:encoded><![CDATA[<p>Following exampel demonstrates how can we create a new thread using C#.<br />
<span id="more-144"></span><br />
i. Create a<strong><a rel="nofollow" href="http://msdn2.microsoft.com/en-us/library/system.threading.threadstart.aspx">ThreadStart</a> delegate</strong>.<br />
ii. Create instance of <a rel="nofollow" href="http://msdn2.microsoft.com/en-us/library/system.threading.thread.aspx">Thread</a> by passing this delegate as a parameter.<br />
iii.Call the <a rel="nofollow" href="http://msdn2.microsoft.com/en-us/library/system.threading.thread.start.aspx">Thread.Start</a> method (i.e. WorkerFunction).</p>

<div class="wp_syntax"><table><tr><td><div class="code"><pre class="csharp" style="font-family:Consolas; monospace;"><span style="color: #0600FF;">using</span> <span style="color: #008080;">System.Threading</span><span style="color: #008000;">;</span>
Thread newThread <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> Thread<span style="color: #000000;">&#40;</span><span style="color: #008000;">new</span> ThreadStart<span style="color: #000000;">&#40;</span>WorkerFunction<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
newThread.<span style="color: #0000FF;">Start</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span></pre></div></td></tr></table></div>

<p>The WorkerFunction could be defined as follows.</p>

<div class="wp_syntax"><table><tr><td><div class="code"><pre class="csharp" style="font-family:Consolas; monospace;"><span style="color: #0600FF;">public</span> <span style="color: #0600FF;">void</span> WorkerFunction<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
  <span style="color: #0600FF;">try</span>
  <span style="color: #000000;">&#123;</span>
    <span style="color: #008080; font-style: italic;">// work</span>
  <span style="color: #000000;">&#125;</span>
  <span style="color: #0600FF;">catch</span> <span style="color: #000000;">&#40;</span>Exception ex<span style="color: #000000;">&#41;</span>
  <span style="color: #000000;">&#123;</span>
    <span style="color: #008080; font-style: italic;">// catch exception</span>
  <span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></div></td></tr></table></div>

<img src="http://eXclusiveMinds.Com/?ak_action=api_record_view&id=144&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://eXclusiveMinds.com/2009/12/02/create-new-thread-in-cshar/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
