<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>ThreadPool.BindHandle</title><link>http://blogs.msdn.com/b/junfeng/archive/2008/12/01/threadpool-bindhandle.aspx</link><description>I mentioned that we can use ThreadPool.BindHandle to implement asynchronous IO. Here are roughly the steps necessary to make it happen: 
 1. Create an overlapped file handle 
 SafeFileHandle handle = CreateFile( 
 filename, 
 Win32.GENERIC_READ_ACCESS</description><dc:language>en-US</dc:language><generator>Telligent Evolution Platform Developer Build (Build: 5.6.50428.7875)</generator><item><title>Multithreading: I/O and the thread pool</title><link>http://blogs.msdn.com/b/junfeng/archive/2008/12/01/threadpool-bindhandle.aspx#9699590</link><pubDate>Thu, 04 Jun 2009 16:22:18 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9699590</guid><dc:creator>ASPInsiders</dc:creator><description>&lt;p&gt;When we started looking at how we could use the thread pool for asynchronous work, I (only!) mentioned&lt;/p&gt;
&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9699590" width="1" height="1"&gt;</description></item><item><title>Multithreading: I/O and the thread pool</title><link>http://blogs.msdn.com/b/junfeng/archive/2008/12/01/threadpool-bindhandle.aspx#9699550</link><pubDate>Thu, 04 Jun 2009 16:10:24 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9699550</guid><dc:creator>LA.NET [EN]</dc:creator><description>&lt;p&gt;When we started looking at how we could use the thread pool for asynchronous work, I (only!) mentioned&lt;/p&gt;
&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9699550" width="1" height="1"&gt;</description></item><item><title>re: ThreadPool.BindHandle</title><link>http://blogs.msdn.com/b/junfeng/archive/2008/12/01/threadpool-bindhandle.aspx#9175612</link><pubDate>Thu, 04 Dec 2008 19:07:18 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9175612</guid><dc:creator>Jelle Hissink</dc:creator><description>&lt;p&gt;junfeng,&lt;/p&gt;
&lt;p&gt;thanks for pointing it out, I must have somehow missed that while reading the documentation.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9175612" width="1" height="1"&gt;</description></item><item><title>re: ThreadPool.BindHandle</title><link>http://blogs.msdn.com/b/junfeng/archive/2008/12/01/threadpool-bindhandle.aspx#9172036</link><pubDate>Thu, 04 Dec 2008 01:03:14 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9172036</guid><dc:creator>Junfeng Zhang</dc:creator><description>&lt;p&gt;In step 4,&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;NativeOverlapped* pOverlapped = overlapped.Pack(iocomplete, bytes);&lt;/p&gt;
&lt;p&gt;This statement implicitly pins the bytes object. The object is unpinned when the overlap is freed. &lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9172036" width="1" height="1"&gt;</description></item><item><title>re: ThreadPool.BindHandle</title><link>http://blogs.msdn.com/b/junfeng/archive/2008/12/01/threadpool-bindhandle.aspx#9171471</link><pubDate>Wed, 03 Dec 2008 22:54:23 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9171471</guid><dc:creator>Jelle Hissink</dc:creator><description>&lt;p&gt;JM,&lt;/p&gt;
&lt;p&gt;Thanks for the pointer tot the GCHandle, hadn't seen that class before. Till now I always try to allocate a buffer using Marshal.MAlloc and reuse it for multiple reads.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9171471" width="1" height="1"&gt;</description></item><item><title>re: ThreadPool.BindHandle</title><link>http://blogs.msdn.com/b/junfeng/archive/2008/12/01/threadpool-bindhandle.aspx#9169737</link><pubDate>Wed, 03 Dec 2008 15:21:48 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9169737</guid><dc:creator>JM</dc:creator><description>&lt;p&gt;@Jelle: you're quite right. Using Marshal every time is slow, though. A better approach is to allocate a GCHandle with type GCHandleType.Pinned, which will prevent the GC from moving the array (and collecting it, incidentally).&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9169737" width="1" height="1"&gt;</description></item><item><title>re: ThreadPool.BindHandle</title><link>http://blogs.msdn.com/b/junfeng/archive/2008/12/01/threadpool-bindhandle.aspx#9166287</link><pubDate>Wed, 03 Dec 2008 00:34:38 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9166287</guid><dc:creator>Jelle Hissink</dc:creator><description>&lt;p&gt;In step 5 when you leave the fixed {} block the p is free to be moved by the GC. Doesn't this buffer needs to be allocated using Marshall.MAlloc and freed after the read has finished?&lt;/p&gt;
&lt;p&gt;Regards&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9166287" width="1" height="1"&gt;</description></item><item><title>infoblog &amp;raquo; ThreadPool.BindHandle</title><link>http://blogs.msdn.com/b/junfeng/archive/2008/12/01/threadpool-bindhandle.aspx#9160751</link><pubDate>Mon, 01 Dec 2008 19:12:19 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9160751</guid><dc:creator>infoblog &amp;raquo; ThreadPool.BindHandle</dc:creator><description>&lt;p&gt;PingBack from &lt;a rel="nofollow" target="_new" href="http://blog.a-foton.ru/index.php/2008/12/01/threadpoolbindhandle/"&gt;http://blog.a-foton.ru/index.php/2008/12/01/threadpoolbindhandle/&lt;/a&gt;&lt;/p&gt;
&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9160751" width="1" height="1"&gt;</description></item></channel></rss>