<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: Use ThreadPool.QueueUserWorkItem With Anonymous Types</title>
	<atom:link href="http://thevalerios.net/matt/2008/05/use-threadpoolqueueuserworkitem-with-anonymous-types/feed/" rel="self" type="application/rss+xml" />
	<link>http://thevalerios.net/matt/2008/05/use-threadpoolqueueuserworkitem-with-anonymous-types/</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Wed, 07 Mar 2012 21:34:45 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
	<item>
		<title>By: Iskren Ivanov</title>
		<link>http://thevalerios.net/matt/2008/05/use-threadpoolqueueuserworkitem-with-anonymous-types/comment-page-1/#comment-71412</link>
		<dc:creator>Iskren Ivanov</dc:creator>
		<pubDate>Fri, 25 Nov 2011 10:09:22 +0000</pubDate>
		<guid isPermaLink="false">http://thevalerios.net/matt/?p=14#comment-71412</guid>
		<description>Instead your own InputData class, you can simply use arrays.</description>
		<content:encoded><![CDATA[<p>Instead your own InputData class, you can simply use arrays.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: flippster</title>
		<link>http://thevalerios.net/matt/2008/05/use-threadpoolqueueuserworkitem-with-anonymous-types/comment-page-1/#comment-62581</link>
		<dc:creator>flippster</dc:creator>
		<pubDate>Wed, 21 Sep 2011 14:09:42 +0000</pubDate>
		<guid isPermaLink="false">http://thevalerios.net/matt/?p=14#comment-62581</guid>
		<description>This is a very nice article. I just wanted to point out that you could also use reflection to get at your type information from within the thread

var blah = new { One = &quot;heheh&quot;, Two= 1234 };

ThreadPool.QueueUserWorkItem(new WaitCallback(ThreadFire), blah);

static void ThreadFire(object objInput)
{
	Lets use reflection
	Type t = objInput.GetType();

	// Get OPC Client property
	PropertyInfo p1 = t.GetProperty(&quot;One&quot;);
	var one_ = (string)p1.GetValue(objInput, null);

	// Get Tag Name property
	PropertyInfo p2 = t.GetProperty(&quot;Two&quot;);
	var tagName = (int)p2.GetValue(objInput, null);
}</description>
		<content:encoded><![CDATA[<p>This is a very nice article. I just wanted to point out that you could also use reflection to get at your type information from within the thread</p>
<p>var blah = new { One = &#8220;heheh&#8221;, Two= 1234 };</p>
<p>ThreadPool.QueueUserWorkItem(new WaitCallback(ThreadFire), blah);</p>
<p>static void ThreadFire(object objInput)<br />
{<br />
	Lets use reflection<br />
	Type t = objInput.GetType();</p>
<p>	// Get OPC Client property<br />
	PropertyInfo p1 = t.GetProperty(&#8220;One&#8221;);<br />
	var one_ = (string)p1.GetValue(objInput, null);</p>
<p>	// Get Tag Name property<br />
	PropertyInfo p2 = t.GetProperty(&#8220;Two&#8221;);<br />
	var tagName = (int)p2.GetValue(objInput, null);<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: flippster</title>
		<link>http://thevalerios.net/matt/2008/05/use-threadpoolqueueuserworkitem-with-anonymous-types/comment-page-1/#comment-62580</link>
		<dc:creator>flippster</dc:creator>
		<pubDate>Wed, 21 Sep 2011 14:08:58 +0000</pubDate>
		<guid isPermaLink="false">http://thevalerios.net/matt/?p=14#comment-62580</guid>
		<description>var blah = new { One = &quot;heheh&quot;, Two= 1234 };

ThreadPool.QueueUserWorkItem(new WaitCallback(ThreadFire), blah);

static void ThreadFire(object objInput)
{
	Lets use reflection
	Type t = objInput.GetType();

	// Get OPC Client property
	PropertyInfo p1 = t.GetProperty(&quot;One&quot;);
	var one_ = (string)p1.GetValue(objInput, null);

	// Get Tag Name property
	PropertyInfo p2 = t.GetProperty(&quot;Two&quot;);
	var tagName = (int)p2.GetValue(objInput, null);
}</description>
		<content:encoded><![CDATA[<p>var blah = new { One = &#8220;heheh&#8221;, Two= 1234 };</p>
<p>ThreadPool.QueueUserWorkItem(new WaitCallback(ThreadFire), blah);</p>
<p>static void ThreadFire(object objInput)<br />
{<br />
	Lets use reflection<br />
	Type t = objInput.GetType();</p>
<p>	// Get OPC Client property<br />
	PropertyInfo p1 = t.GetProperty(&#8220;One&#8221;);<br />
	var one_ = (string)p1.GetValue(objInput, null);</p>
<p>	// Get Tag Name property<br />
	PropertyInfo p2 = t.GetProperty(&#8220;Two&#8221;);<br />
	var tagName = (int)p2.GetValue(objInput, null);<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: pepepaco</title>
		<link>http://thevalerios.net/matt/2008/05/use-threadpoolqueueuserworkitem-with-anonymous-types/comment-page-1/#comment-58942</link>
		<dc:creator>pepepaco</dc:creator>
		<pubDate>Thu, 18 Aug 2011 23:21:38 +0000</pubDate>
		<guid isPermaLink="false">http://thevalerios.net/matt/?p=14#comment-58942</guid>
		<description>the easiest way to notify the main thread is to pass an Action parmeter along with the data parameters besides the Action to be executed. for example:

ThreadPoolHelper.QueueUserWorkItem(
    new { Name = &quot;Matt&quot;, Age = 26, CallbackWhendone = ExecWhendone },
    (data) =&gt;
    {
        string name = data.Name;
        int age = data.Age;        
        // Long-running computation
        data.CallbackWhendone();
    });

//where ExecWhendone is the method to be called when the calculation is done.(I have not tested it)</description>
		<content:encoded><![CDATA[<p>the easiest way to notify the main thread is to pass an Action parmeter along with the data parameters besides the Action to be executed. for example:</p>
<p>ThreadPoolHelper.QueueUserWorkItem(<br />
    new { Name = &#8220;Matt&#8221;, Age = 26, CallbackWhendone = ExecWhendone },<br />
    (data) =&gt;<br />
    {<br />
        string name = data.Name;<br />
        int age = data.Age;<br />
        // Long-running computation<br />
        data.CallbackWhendone();<br />
    });</p>
<p>//where ExecWhendone is the method to be called when the calculation is done.(I have not tested it)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: The Easiest Way To Run Async Code &#8211; Reading #FunnelWeblog Code &#124; GuruStop.NET</title>
		<link>http://thevalerios.net/matt/2008/05/use-threadpoolqueueuserworkitem-with-anonymous-types/comment-page-1/#comment-41060</link>
		<dc:creator>The Easiest Way To Run Async Code &#8211; Reading #FunnelWeblog Code &#124; GuruStop.NET</dc:creator>
		<pubDate>Tue, 15 Mar 2011 21:06:41 +0000</pubDate>
		<guid isPermaLink="false">http://thevalerios.net/matt/?p=14#comment-41060</guid>
		<description>[...] Use ThreadPool.QueueUserWorkItem With Anonymous Types [...]</description>
		<content:encoded><![CDATA[<p>[...] Use ThreadPool.QueueUserWorkItem With Anonymous Types [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dodgyrabbit</title>
		<link>http://thevalerios.net/matt/2008/05/use-threadpoolqueueuserworkitem-with-anonymous-types/comment-page-1/#comment-15975</link>
		<dc:creator>Dodgyrabbit</dc:creator>
		<pubDate>Mon, 22 Mar 2010 20:49:28 +0000</pubDate>
		<guid isPermaLink="false">http://thevalerios.net/matt/?p=14#comment-15975</guid>
		<description>By utilizing closures with anonymous methods, you can simplify this more.

For example:

string input1 = &quot;Input data 1&quot;; 
string input2 = &quot;Input data 2&quot;; 
ThreadPool.QueueUserWorkItem(delegate
        {
                // Safe to use enclosing variables here using closures
                Debug.WriteLine(input1);
                Debug.WriteLine(input2);
        }


Here is a similar question:
http://stackoverflow.com/questions/738139/threadpool-queueuserworkitem-with-a-lambda-expression-and-anonymous-method</description>
		<content:encoded><![CDATA[<p>By utilizing closures with anonymous methods, you can simplify this more.</p>
<p>For example:</p>
<p>string input1 = &#8220;Input data 1&#8243;;<br />
string input2 = &#8220;Input data 2&#8243;;<br />
ThreadPool.QueueUserWorkItem(delegate<br />
        {<br />
                // Safe to use enclosing variables here using closures<br />
                Debug.WriteLine(input1);<br />
                Debug.WriteLine(input2);<br />
        }</p>
<p>Here is a similar question:<br />
<a href="http://stackoverflow.com/questions/738139/threadpool-queueuserworkitem-with-a-lambda-expression-and-anonymous-method" rel="nofollow">http://stackoverflow.com/questions/738139/threadpool-queueuserworkitem-with-a-lambda-expression-and-anonymous-method</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Drew</title>
		<link>http://thevalerios.net/matt/2008/05/use-threadpoolqueueuserworkitem-with-anonymous-types/comment-page-1/#comment-14192</link>
		<dc:creator>Drew</dc:creator>
		<pubDate>Mon, 04 Jan 2010 20:23:13 +0000</pubDate>
		<guid isPermaLink="false">http://thevalerios.net/matt/?p=14#comment-14192</guid>
		<description>What is the reference &quot;s&quot; in the following?
s =&gt; callback((T)s)

I&#039;m assuming it&#039;s a reference to an anonymous object, but I&#039;m not sure.</description>
		<content:encoded><![CDATA[<p>What is the reference &#8220;s&#8221; in the following?<br />
s =&gt; callback((T)s)</p>
<p>I&#8217;m assuming it&#8217;s a reference to an anonymous object, but I&#8217;m not sure.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Vytheese</title>
		<link>http://thevalerios.net/matt/2008/05/use-threadpoolqueueuserworkitem-with-anonymous-types/comment-page-1/#comment-10248</link>
		<dc:creator>Vytheese</dc:creator>
		<pubDate>Mon, 20 Jul 2009 05:47:08 +0000</pubDate>
		<guid isPermaLink="false">http://thevalerios.net/matt/?p=14#comment-10248</guid>
		<description>This makes me clearer. Thanks a lot.</description>
		<content:encoded><![CDATA[<p>This makes me clearer. Thanks a lot.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Madhu</title>
		<link>http://thevalerios.net/matt/2008/05/use-threadpoolqueueuserworkitem-with-anonymous-types/comment-page-1/#comment-9698</link>
		<dc:creator>Madhu</dc:creator>
		<pubDate>Fri, 05 Jun 2009 05:39:57 +0000</pubDate>
		<guid isPermaLink="false">http://thevalerios.net/matt/?p=14#comment-9698</guid>
		<description>Thanku very much. Post very useful. Was able to solve my problem of not being able to send multiple parameters using threads.</description>
		<content:encoded><![CDATA[<p>Thanku very much. Post very useful. Was able to solve my problem of not being able to send multiple parameters using threads.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: matt</title>
		<link>http://thevalerios.net/matt/2008/05/use-threadpoolqueueuserworkitem-with-anonymous-types/comment-page-1/#comment-9632</link>
		<dc:creator>matt</dc:creator>
		<pubDate>Fri, 29 May 2009 04:32:19 +0000</pubDate>
		<guid isPermaLink="false">http://thevalerios.net/matt/?p=14#comment-9632</guid>
		<description>Hey everyone,
Sorry about the formatting mixup.  Some anonymous type annotations (&lt;T&gt;) had been eaten by the blog engine.  Hopefully this update fixes everything, though it&#039;s not as clean as I&#039;d like (trying VS2010 Beta + Live Writer on Win7 RC). Let me know if I missed something.</description>
		<content:encoded><![CDATA[<p>Hey everyone,<br />
Sorry about the formatting mixup.  Some anonymous type annotations (&lt;T&gt;) had been eaten by the blog engine.  Hopefully this update fixes everything, though it&#8217;s not as clean as I&#8217;d like (trying VS2010 Beta + Live Writer on Win7 RC). Let me know if I missed something.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

