<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" media="screen" href="/styles/xslt/rss.xslt"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:media="http://search.yahoo.com/mrss/" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" xmlns:c9="http://channel9.msdn.com">
<channel>
	<title>Channel 9 - Discussions by ploe</title>
	<atom:link rel="self" type="application/rss+xml" href="http://channel9.msdn.com/Niners/ploe/Discussions/RSS"></atom:link>
	<image>
		<url>http://mschnlnine.vo.llnwd.net/d1/Dev/App_Themes/C9/images/feedimage.png</url>
		<title>Channel 9 - Discussions by ploe</title>
		<link>http://channel9.msdn.com/Niners/ploe/Discussions</link>
	</image>
	<description>Channel 9 keeps you up to date with the latest news and behind the scenes info from Microsoft that developers love to keep up with. From LINQ to SilverLight – Watch videos and hear about all the cool technologies coming and the people behind them.</description>
	<link>http://channel9.msdn.com/Niners/ploe/Discussions</link>
	<language>en</language>
	<pubDate>Mon, 20 May 2013 14:26:31 GMT</pubDate>
	<lastBuildDate>Mon, 20 May 2013 14:26:31 GMT</lastBuildDate>
	<generator>Rev9</generator>
	<c9:totalResults>0</c9:totalResults>
	<c9:pageCount>0</c9:pageCount>
	<c9:pageSize>0</c9:pageSize>
	<item>
		<title>Tech Off - Form.Text does not update</title>
		<description><![CDATA[<p><blockquote><div class="quoteUser">W3bbo said:</div><div class="quoteText">
<blockquote>
<div class="quoteUser">ploe said:</div>
<div class="quoteText">*snip*</div>
</blockquote>
<p>Can you post your code?</p>
</div></blockquote>
<p>I'm an idiot. I couldn't find the bug because it wasn't in the window's code, but our base class that it extends. The other windows where the title update&nbsp;does work inherits a different base class.</p>
<p>&nbsp;</p>
<p>In our base class we disabled painting while the window was in a state of populating data (because we were getting flicker) with this line:</p>
<p>SendMessage(this.Handle, WM_SETREDRAW, 0, IntPtr.Zero);</p>
<p>&nbsp;</p>
<p>We re-enabled painting when it is done populating with this line:</p>
<p>SendMessage(this.Handle, WM_SETREDRAW, 1, IntPtr.Zero);</p>
<p>&nbsp;</p>
<p>Then we call Invalidate(true). But that just invalidates the client area, not the non-client area, hence why the title bar was not re-painting.</p>
<p>&nbsp;</p>
<p>Solution:</p>
<p>Invalidate and paint the ENTIRE window by calling: InvalidateRect() and then UpdateWindow().</p>
<p>&nbsp;</p>
<p>Sorry for the wild goose chase.</p></p>]]></description>
		<link>http://channel9.msdn.com/Forums/TechOff/549301-FormText-does-not-update/93c8914eb0ef4d18ac8d9deb000e2d36#93c8914eb0ef4d18ac8d9deb000e2d36</link>
		<pubDate>Wed, 12 May 2010 19:38:33 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/TechOff/549301-FormText-does-not-update/93c8914eb0ef4d18ac8d9deb000e2d36#93c8914eb0ef4d18ac8d9deb000e2d36</guid>
		<dc:creator>ploe</dc:creator>
		<slash:comments>7</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/ploe/Discussions/RSS</wfw:commentRss>
	</item>
	<item>
		<title>Tech Off - Form.Text does not update</title>
		<description><![CDATA[<p><blockquote><div class="quoteUser">W3bbo said:</div><div class="quoteText">
<ul>
<li>Is the .Text property being set on the same thread that instantiated the form?
</li><li>Set a breakpoint to make sure it's been hit </li><li>Make a copy of your form's code and reduce it down until you get the smallest amount of code that reproduces the problem, then compare it to a working sample.
</li><li></li></ul>
</div></blockquote>
<p>I can't seem to find a different between the windows.</p>
<p>&nbsp;</p>
<p>I have a method called UpdateTitle() that actually updates the Form's Text. InvokeRequired always returns false, so it's definately not in the wrong Thread. Nothing related to this window is multi-threaded so this was not surprising.</p>
<p>&nbsp;</p>
<p>When I put in a breakpoint, the title does update. I suspect that's because Visual Studio takes focus and when I go back to the window, it triggers a re-paint of the non-client area. The title change&nbsp;also shows up if I minimize, then maximize the window.</p></p>]]></description>
		<link>http://channel9.msdn.com/Forums/TechOff/549301-FormText-does-not-update/3647a47a985e43559e659deb000e2cda#3647a47a985e43559e659deb000e2cda</link>
		<pubDate>Wed, 12 May 2010 18:59:24 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/TechOff/549301-FormText-does-not-update/3647a47a985e43559e659deb000e2cda#3647a47a985e43559e659deb000e2cda</guid>
		<dc:creator>ploe</dc:creator>
		<slash:comments>7</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/ploe/Discussions/RSS</wfw:commentRss>
	</item>
	<item>
		<title>Tech Off - Form.Text does not update</title>
		<description><![CDATA[<p>I have this one window where when I set the Text property of the Form it does not update the title bar. I am 100% sure my code is being called and the Text value is being changed. It's just not physically painting it on the screen.</p>
<p>&nbsp;</p>
<p>I have about 100 or so Forms and this is the only Form that does this. I've compared properties with a window that does work and can't see anything odd that I'm doing in the broken Form. Has anyone run accross this or have an idea of things I can check?</p>]]></description>
		<link>http://channel9.msdn.com/Forums/TechOff/549301-FormText-does-not-update/549301#549301</link>
		<pubDate>Tue, 11 May 2010 13:34:33 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/TechOff/549301-FormText-does-not-update/549301#549301</guid>
		<dc:creator>ploe</dc:creator>
		<slash:comments>7</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/ploe/Discussions/RSS</wfw:commentRss>
	</item>
	<item>
		<title>Tech Off - Odd C# multiplication behavior</title>
		<description><![CDATA[<p><blockquote><div class="quoteUser">Dexter said:</div><div class="quoteText">
<blockquote>
<div class="quoteUser">ploe said:</div>
<div class="quoteText">*snip*</div>
</blockquote>
<p></p>
<p>&nbsp;</p>
<p>Yes, it can. But try -78.884687963873147 instead. Or -78.884687963873143 <img src="http://ecn.channel9.msdn.com/o9/content/images/emoticons/emotion-1.gif" alt="Smiley"></p>
<p>&nbsp;</p>
<p>The last digit is kind of bogus.</p>
</div></blockquote>
<p>You're right! Those other values don't work. The '8'&nbsp;is bogus and&nbsp;it appears as though the '4' is also non-existent. Do you think it's just an odd behavior of the debugger?</p></p>]]></description>
		<link>http://channel9.msdn.com/Forums/TechOff/543704-Odd-C-multiplication-behavior/2c277a5df82c4d8599dd9deb000d618e#2c277a5df82c4d8599dd9deb000d618e</link>
		<pubDate>Tue, 13 Apr 2010 17:27:35 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/TechOff/543704-Odd-C-multiplication-behavior/2c277a5df82c4d8599dd9deb000d618e#2c277a5df82c4d8599dd9deb000d618e</guid>
		<dc:creator>ploe</dc:creator>
		<slash:comments>17</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/ploe/Discussions/RSS</wfw:commentRss>
	</item>
	<item>
		<title>Tech Off - Odd C# multiplication behavior</title>
		<description><![CDATA[<p><blockquote><div class="quoteUser">Dexter said:</div><div class="quoteText">
<blockquote>
<div class="quoteUser">ploe said:</div>
<div class="quoteText">*snip*</div>
</blockquote>
<p>Wait a moment, where did that value come from anyway?</p>
<p>&nbsp;</p>
<p>It has 17 significant digits and that's more than double can represent. Is that a constant in your code? In that case you need to make it a decimal in the first place. Like:</p>
<p>&nbsp;</p>
<p>const decimal x = -78.884687963873148m;</p>
<p>&nbsp;</p>
<p>Note the m suffix. That tells the compiler it is a decimal literal. Otherwise double is implied.</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
</div></blockquote>
<p>It's definately a double, I got the value from the assembly as a double with that value in it. I've just been using a constant in my posts so that it's more understandable.</p>
<p>&nbsp;</p>
<p>If you put that value in your watch of VS it does say the type is a double.</p>
<p>&nbsp;</p>
<p>It's all a little confusing. If you run this bit of code you see that a double can store this value:</p>
<p>double d = -78.884687963873148;</p>
<p>Console.WriteLine(d.ToString(&quot;R&quot;));</p></p>]]></description>
		<link>http://channel9.msdn.com/Forums/TechOff/543704-Odd-C-multiplication-behavior/28c480af4d234885b96d9deb000d60dd#28c480af4d234885b96d9deb000d60dd</link>
		<pubDate>Tue, 13 Apr 2010 16:02:12 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/TechOff/543704-Odd-C-multiplication-behavior/28c480af4d234885b96d9deb000d60dd#28c480af4d234885b96d9deb000d60dd</guid>
		<dc:creator>ploe</dc:creator>
		<slash:comments>17</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/ploe/Discussions/RSS</wfw:commentRss>
	</item>
	<item>
		<title>Tech Off - Odd C# multiplication behavior</title>
		<description><![CDATA[<p><blockquote><div class="quoteUser">W3bbo said:</div><div class="quoteText">
<blockquote>
<div class="quoteUser">ploe said:</div>
<div class="quoteText">*snip*</div>
</blockquote>
<p>I <em>think</em> that's because Decimal's ToString() method by default truncates the results.</p>
<p>&nbsp;</p>
<p>Try working with Decimals throughout your program though.</p>
</div></blockquote>
<p>Unfortunately the double comes from an external assembly.</p>
<p>&nbsp;</p>
<p>(-78.884687963873148M).ToString() is not truncated though, so I feel like I'm losing data in the typecast.</p>
<p>&nbsp;</p>
<p>The only thing that seems to convert it correctly is if I do this:<br>
decimal d = Decimal.Parse((-78.884687963873148).ToString(&quot;R&quot;));</p>
<p>...not exactly efficient.</p></p>]]></description>
		<link>http://channel9.msdn.com/Forums/TechOff/543704-Odd-C-multiplication-behavior/918a900414f44d08aa289deb000d60af#918a900414f44d08aa289deb000d60af</link>
		<pubDate>Tue, 13 Apr 2010 15:52:55 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/TechOff/543704-Odd-C-multiplication-behavior/918a900414f44d08aa289deb000d60af#918a900414f44d08aa289deb000d60af</guid>
		<dc:creator>ploe</dc:creator>
		<slash:comments>17</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/ploe/Discussions/RSS</wfw:commentRss>
	</item>
	<item>
		<title>Tech Off - Odd C# multiplication behavior</title>
		<description><![CDATA[<p><blockquote><div class="quoteUser">W3bbo said:</div><div class="quoteText">
<blockquote>
<div class="quoteUser">phreaks said:</div>
<div class="quoteText">*snip*</div>
</blockquote>
<p><a href="http://sine.codeplex.com">http://sine.codeplex.com</a> &lt;-- My arbitrary-prescision library for .NET; note that I did some major refactoring in the latest revision and my code is unstable, unusable, gives inaccurate (if not just plain
<em>wrong</em>) results, and is otherwise <em>unfit for purpose</em>. Use with caution. The earlier revisions (and the available download release) still work fine.</p>
<p>&nbsp;</p>
<p><a href="http://intx.codeplex.com">http://intx.codeplex.com</a> &lt;-- An integer-only library for .NET far,
<em>far</em> superior to my own... but only does integers. The IntX class in this library is superior to the BigInteger class in .NET4.0 in most circumstances, so it's worth checking out.</p>
<p>&nbsp;</p>
<p>EDIT: I see that F# comes with its own BigRational class. Note that it's a rational number (that is, any number representable by an integer numerator and denominator) so whilst it will always give you 'purer' results than a floating/decimal library like
 mine it won't necessarily be faster.</p>
</div></blockquote>
<p>Okay I seem to have grasped a better understanding of the problem I'm running into:</p>
<p>&nbsp;</p>
<p>The initial type I have is a double with the value -78.884687963873148. I typecast it to a decimal because I need slightly more precision on it based on the math I'm going to do. But typecasting the double -78.884687963873148 to a decimal, I actually lose
 precision.</p>
<p>(decimal)-78.884687963873148 = -78.8846879638731</p>
<p>&nbsp;</p>
<p>:/</p></p>]]></description>
		<link>http://channel9.msdn.com/Forums/TechOff/543704-Odd-C-multiplication-behavior/8ce736bca8824ab2b2e19deb000d6024#8ce736bca8824ab2b2e19deb000d6024</link>
		<pubDate>Tue, 13 Apr 2010 15:30:07 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/TechOff/543704-Odd-C-multiplication-behavior/8ce736bca8824ab2b2e19deb000d6024#8ce736bca8824ab2b2e19deb000d6024</guid>
		<dc:creator>ploe</dc:creator>
		<slash:comments>17</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/ploe/Discussions/RSS</wfw:commentRss>
	</item>
	<item>
		<title>Tech Off - Odd C# multiplication behavior</title>
		<description><![CDATA[<p>When I run this bit of code '-78.884687963873148 * Math.Pow(10, 13)'&nbsp;it returns the value:&nbsp;-788846879638731.5. I would expect it to return -788846879638731.48. Is there an alternative to the way I'm doing it above to get it to return the expected value?</p>]]></description>
		<link>http://channel9.msdn.com/Forums/TechOff/543704-Odd-C-multiplication-behavior/543704#543704</link>
		<pubDate>Tue, 13 Apr 2010 12:11:44 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/TechOff/543704-Odd-C-multiplication-behavior/543704#543704</guid>
		<dc:creator>ploe</dc:creator>
		<slash:comments>17</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/ploe/Discussions/RSS</wfw:commentRss>
	</item>
	<item>
		<title>Tech Off - Deprecate Class that&#39;s not mine</title>
		<description><![CDATA[<p>Is there a way to deprecate a C# class that isn't in my assembly?</p>
<p>&nbsp;</p>
<p>In our assembly, we have our own implementation of what the built in MessageBox class. It's called PopupBox. I'd like to discourage the use of MessageBox in our application. I thought a good way would be to make MessageBox deprecated so that it threw a compiler
 warning.</p>
<p>&nbsp;</p>
<p>If this isn't possible, can you suggest an alternative?</p>]]></description>
		<link>http://channel9.msdn.com/Forums/TechOff/529934-Deprecate-Class-thats-not-mine/529934#529934</link>
		<pubDate>Wed, 17 Feb 2010 20:37:59 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/TechOff/529934-Deprecate-Class-thats-not-mine/529934#529934</guid>
		<dc:creator>ploe</dc:creator>
		<slash:comments>3</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/ploe/Discussions/RSS</wfw:commentRss>
	</item>
	<item>
		<title>Tech Off - Generic Base class problem</title>
		<description><![CDATA[<p><blockquote><div class="quoteUser">cdwatkins said:</div><div class="quoteText">
<p>Your talking about a contra/co- variance problem.&nbsp; The problem is that IList&lt;Bob&gt; isnt assignable to IList&lt;Person&gt; even though Bob is a type of person.&nbsp; They fixed this problem in .NET 4.</p>
</div></blockquote>
<p>Probably not the solution you are looking for, but you could do this:</p>
<p>&nbsp;</p>
<p>Have only one Customer class and make your 'special' members internal so only you can use them. If it's in a different assembly from where you need it you can use this to gain access to the internal members:
<a href="http://msdn.microsoft.com/en-us/library/0tke9fxk.aspx">http://msdn.microsoft.com/en-us/library/0tke9fxk.aspx</a></p></p>]]></description>
		<link>http://channel9.msdn.com/Forums/TechOff/251259-Generic-Base-class-problem/7c7ca35a05a4447db2679dea014fe0a1#7c7ca35a05a4447db2679dea014fe0a1</link>
		<pubDate>Tue, 16 Feb 2010 01:45:22 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/TechOff/251259-Generic-Base-class-problem/7c7ca35a05a4447db2679dea014fe0a1#7c7ca35a05a4447db2679dea014fe0a1</guid>
		<dc:creator>ploe</dc:creator>
		<slash:comments>4</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/ploe/Discussions/RSS</wfw:commentRss>
	</item>
	<item>
		<title>Tech Off - Stumbling on Basic Serial Port IO</title>
		<description><![CDATA[<p><blockquote><div class="quoteUser">ploe said:</div><div class="quoteText">
<blockquote>
<div class="quoteUser">ScanIAm said:</div>
<div class="quoteText">*snip*</div>
</blockquote>
<p>Thanks. I knew it was going to be something little. I appended the equivalent of '\r\n' to the command I was sending at it wrote back the command I sent plus the response.
<img src="http://ecn.channel9.msdn.com/o9/content/images/emoticons/emotion-1.gif" alt="Smiley"></p>
<p>&nbsp;</p>
<p>Edit: It was a GPRS/GSM device.</p>
</div></blockquote>
<p>So people don't have to re-invent the wheel, this was the wrapper I ended up writing...may be of use to someone.</p>
<p>&nbsp;</p>
<p>EDIT: code formatter doesn't work too well :/</p>
<p>&nbsp;</p>
<p></p>
<pre class="brush: csharp">
    /// &lt;summary&gt;
    /// Class that allows for serial communication in Windows.
    /// &lt;/summary&gt;
    public class SerialCom : IDisposable
    {
        #region Fields
 
        /// &lt;summary&gt;
        /// The baud rate at which the communications device operates.
        /// &lt;/summary&gt;
        private readonly int baudRate;
 
        /// &lt;summary&gt;
        /// The number of bits in the bytes to be transmitted and received.
        /// &lt;/summary&gt;
        private readonly byte byteSize;
 
        /// &lt;summary&gt;
        /// The system handle to the serial port connection ('file' handle).
        /// &lt;/summary&gt;
        private IntPtr handle = IntPtr.Zero;
 
        /// &lt;summary&gt;
        /// The parity scheme to be used.
        /// &lt;/summary&gt;
        private readonly Parity parity;
 
        /// &lt;summary&gt;
        /// The name of the serial port to connect to.
        /// &lt;/summary&gt;
        private readonly string portName;
 
        /// &lt;summary&gt;
        /// The number of bits in the bytes to be transmitted and received.
        /// &lt;/summary&gt;
        private readonly StopBits stopBits;
 
        #endregion
 
        /// &lt;summary&gt;
        /// Creates a new instance of SerialCom.
        /// &lt;/summary&gt;
        /// &lt;param&gt;The name of the serial port to connect to&lt;/param&gt;
        /// &lt;param&gt;The baud rate at which the communications device operates&lt;/param&gt;
        /// &lt;param&gt;The number of stop bits to be used&lt;/param&gt;
        /// &lt;param&gt;The parity scheme to be used&lt;/param&gt;
        /// &lt;param&gt;The number of bits in the bytes to be transmitted and received&lt;/param&gt;
        public SerialCom(string portName, int baudRate, StopBits stopBits, Parity parity, byte byteSize)
        {
            if (stopBits == StopBits.None)
                throw new ArgumentException(&quot;stopBits cannot be StopBits.None&quot;, &quot;stopBits&quot;);
            if (byteSize &lt; 5 || byteSize &gt; 8)
                throw new ArgumentOutOfRangeException(&quot;The number of data bits must be 5 to 8 bits.&quot;, &quot;byteSize&quot;);
            if (baudRate &lt; 110 || baudRate &gt; 256000)
                throw new ArgumentOutOfRangeException(&quot;Invalid baud rate specified.&quot;, &quot;baudRate&quot;);
            if ((byteSize == 5 &amp;&amp; stopBits == StopBits.Two) || (stopBits == StopBits.OnePointFive &amp;&amp; byteSize &gt; 5))
                throw new ArgumentException(&quot;The use of 5 data bits with 2 stop bits is an invalid combination, &quot; &#43;
                    &quot;as is 6, 7, or 8 data bits with 1.5 stop bits.&quot;);
 
            this.portName = portName;
            this.baudRate = baudRate;
            this.byteSize = byteSize;
            this.stopBits = stopBits;
            this.parity = parity;
        }
 
        /// &lt;summary&gt;
        /// Creates a new instance of SerialCom.
        /// &lt;/summary&gt;
        /// &lt;param&gt;The name of the serial port to connect to&lt;/param&gt;
        /// &lt;param&gt;The baud rate at which the communications device operates&lt;/param&gt;
        /// &lt;param&gt;The number of stop bits to be used&lt;/param&gt;
        /// &lt;param&gt;The parity scheme to be used&lt;/param&gt;
        public SerialCom(string portName, int baudRate, StopBits stopBits, Parity parity)
            : this(portName, baudRate, stopBits, parity, 8) { }
 
        /// &lt;summary&gt;
        /// Disconnects and disposes of the SerialCom instance.
        /// &lt;/summary&gt;
        public void Dispose()
        {
            if (handle != IntPtr.Zero)
            {
                CloseHandle(handle);
                handle = IntPtr.Zero;
            }
        }
 
        /// &lt;summary&gt;
        /// Flushes the serial I/O buffers.
        /// &lt;/summary&gt;
        /// &lt;returns&gt;Whether or not the operation succeeded&lt;/returns&gt;
        public bool Flush()
        {
            FailIfNotConnected();
 
            const int PURGE_RXCLEAR = 0x0008; // input buffer
            const int PURGE_TXCLEAR = 0x0004; // output buffer
            return PurgeComm(handle, PURGE_RXCLEAR | PURGE_TXCLEAR);
        }
 
        /// &lt;summary&gt;
        /// Opens and initializes the serial connection.
        /// &lt;/summary&gt;
        /// &lt;returns&gt;Whether or not the operation succeeded&lt;/returns&gt;
        public bool Open()
        {
            handle = CreateFile(this.portName, FileAccess.ReadWrite, FileShare.None,
                IntPtr.Zero, FileMode.Open, 0, IntPtr.Zero);
            if (handle == IntPtr.Zero) return false;
 
            if (ConfigureSerialPort()) return true;
            else
            {
                Dispose();
                return false;
            }
        }
 
        /// &lt;summary&gt;
        /// Reads any bytes that have been received and writes them to the specified array.
        /// &lt;/summary&gt;
        /// &lt;param&gt;The array to write the read data to&lt;/param&gt;
        /// &lt;returns&gt;The number of bytes read (-1 if error)&lt;/returns&gt;
        public int Read(byte[] data)
        {
            FailIfNotConnected();
            if (data == null) return 0;
 
            int bytesRead;
            if (ReadFile(handle, data, data.Length, out bytesRead, 0))
                return bytesRead;
            return -1;
        }
 
        /// &lt;summary&gt;
        /// Reads any data that has been received as a string.
        /// &lt;/summary&gt;
        /// &lt;param&gt;The maximum number of bytes to read&lt;/param&gt;
        /// &lt;returns&gt;The data received (null if no data)&lt;/returns&gt;
        public string ReadString(int maxBytesToRead)
        {
            if (maxBytesToRead &lt; 1) throw new ArgumentOutOfRangeException(&quot;maxBytesToRead&quot;);
 
            byte[] bytes = new byte[maxBytesToRead];
            int numBytes = Read(bytes);
            string data = ASCIIEncoding.ASCII.GetString(bytes, 0, numBytes);
            return data;
        }
 
        /// &lt;summary&gt;
        /// Transmits the specified array of bytes.
        /// &lt;/summary&gt;
        /// &lt;param&gt;The bytes to write&lt;/param&gt;
        /// &lt;returns&gt;The number of bytes written (-1 if error)&lt;/returns&gt;
        public int Write(byte[] data)
        {
            FailIfNotConnected();
            if (data == null) return 0;
 
            int bytesWritten;
            if (WriteFile(handle, data, data.Length, out bytesWritten, 0))
                return bytesWritten;
            return -1;
        }
 
        /// &lt;summary&gt;
        /// Transmits the specified string.
        /// &lt;/summary&gt;
        /// &lt;param&gt;The string to write&lt;/param&gt;
        /// &lt;returns&gt;The number of bytes written (-1 if error)&lt;/returns&gt;
        public int Write(string data)
        {
            FailIfNotConnected();
 
            // convert the string to bytes
            byte[] bytes;
            if (data == null) bytes = null;
            else bytes = ASCIIEncoding.ASCII.GetBytes(data);
            return Write(bytes);
        }
 
        /// &lt;summary&gt;
        /// Transmits the specified string and appends the carriage return to the end
        /// if it does not exist.
        /// &lt;/summary&gt;
        /// &lt;remarks&gt;
        /// Note that the string must end in '\r\n' before any serial device will interpret the data
        /// sent. For ease of programmability, this method should be used instead of Write() when you
        /// want to automatically execute the specified command string.
        /// &lt;/remarks&gt;
        /// &lt;param&gt;The string to write&lt;/param&gt;
        /// &lt;returns&gt;The number of bytes written (-1 if error)&lt;/returns&gt;
        public int WriteLine(string data)
        {
            if (data != null &amp;&amp; !data.EndsWith(&quot;\r\n&quot;))
                data &#43;= &quot;\r\n&quot;;
            return Write(data);
        }
 
        #region Private Helpers
 
        /// &lt;summary&gt;
        /// Configures the serial device based on the connection parameters pased in by the user.
        /// &lt;/summary&gt;
        /// &lt;returns&gt;Whether or not the operation succeeded&lt;/returns&gt;
        private bool ConfigureSerialPort()
        {
            DCB serialConfig = new DCB();
            if (GetCommState(handle, ref serialConfig))
            {
                // setup the DCB struct with the serial settings we need
                serialConfig.BaudRate = (uint)this.baudRate;
                serialConfig.ByteSize = this.byteSize;
                serialConfig.fBinary = 1; // must be true
                serialConfig.fDtrControl = 1; // DTR_CONTROL_ENABLE &quot;Enables the DTR line when the device is opened and leaves it on.&quot;
                serialConfig.fAbortOnError = 0; // false
                serialConfig.fTXContinueOnXoff = 0; // false
 
                serialConfig.fParity = 1; // true so that the Parity member is looked at
                switch (this.parity)
                {
                    case Parity.Even:
                        serialConfig.Parity = 2;
                        break;
                    case Parity.Mark:
                        serialConfig.Parity = 3;
                        break;
                    case Parity.Odd:
                        serialConfig.Parity = 1;
                        break;
                    case Parity.Space:
                        serialConfig.Parity = 4;
                        break;
                    case Parity.None:
                    default:
                        serialConfig.Parity = 0;
                        break;
                }
                switch (this.stopBits)
                {
                    case StopBits.One:
                        serialConfig.StopBits = 0;
                        break;
                    case StopBits.OnePointFive:
                        serialConfig.StopBits = 1;
                        break;
                    case StopBits.Two:
                        serialConfig.StopBits = 2;
                        break;
                    case StopBits.None:
                    default:
                        throw new ArgumentException(&quot;stopBits cannot be StopBits.None&quot;);
                }
 
                if (SetCommState(handle, ref serialConfig))
                {
                    // set the serial connection timeouts
                    COMMTIMEOUTS timeouts = new COMMTIMEOUTS();
                    timeouts.ReadIntervalTimeout = 1;
                    timeouts.ReadTotalTimeoutMultiplier = 0;
                    timeouts.ReadTotalTimeoutConstant = 0;
                    timeouts.WriteTotalTimeoutMultiplier = 0;
                    timeouts.WriteTotalTimeoutConstant = 0;
                    if (SetCommTimeouts(handle, ref timeouts))
                        return true;
                    else return false;
                }
                else return false;
            }
            else return false;
        }
 
        /// &lt;summary&gt;
        /// Helper that throws a InvalidOperationException if we don't have a serial connection.
        /// &lt;/summary&gt;
        private void FailIfNotConnected()
        {
            if (handle == IntPtr.Zero)
                throw new InvalidOperationException(&quot;You must be connected to the serial port before performing this operation.&quot;);
        }
 
        #endregion
 
        #region Native Helpers
 
        // Used to get a handle to the serial port so that we can read/write to it.
        [DllImport(&quot;kernel32.dll&quot;, SetLastError = true, CharSet = CharSet.Auto)]
        static extern IntPtr CreateFile(string fileName,
           [MarshalAs(UnmanagedType.U4)] FileAccess fileAccess,
           [MarshalAs(UnmanagedType.U4)] FileShare fileShare,
           IntPtr securityAttributes,
           [MarshalAs(UnmanagedType.U4)] FileMode creationDisposition,
           int flags,
           IntPtr template);
 
        // Used to close the handle to the serial port.
        [DllImport(&quot;kernel32.dll&quot;, SetLastError = true)]
        static extern bool CloseHandle(IntPtr hObject);
 
        /// &lt;summary&gt;
        /// Defines the control setting for a serial communications device.
        /// &lt;/summary&gt;
        [StructLayout(LayoutKind.Sequential)]
        struct DCB
        {
            public int DCBlength;
            public uint BaudRate;
            public uint Flags;
            public ushort wReserved;
            public ushort XonLim;
            public ushort XoffLim;
            public byte ByteSize;
            public byte Parity;
            public byte StopBits;
            public sbyte XonChar;
            public sbyte XoffChar;
            public sbyte ErrorChar;
            public sbyte EofChar;
            public sbyte EvtChar;
            public ushort wReserved1;
            public uint fBinary;
            public uint fParity;
            public uint fOutxCtsFlow;
            public uint fOutxDsrFlow;
            public uint fDtrControl;
            public uint fDsrSensitivity;
            public uint fTXContinueOnXoff;
            public uint fOutX;
            public uint fInX;
            public uint fErrorChar;
            public uint fNull;
            public uint fRtsControl;
            public uint fAbortOnError;
        }
 
        // Used to get the state of the serial port so that we can configure it.
        [DllImport(&quot;kernel32.dll&quot;)]
        static extern bool GetCommState(IntPtr hFile, ref DCB lpDCB);
 
        // Used to configure the serial port.
        [DllImport(&quot;kernel32.dll&quot;)]
        static extern bool SetCommState(IntPtr hFile, [In] ref DCB lpDCB);
 
        /// &lt;summary&gt;
        /// Contains the time-out parameters for a communications device.
        /// &lt;/summary&gt;
        [StructLayout(LayoutKind.Sequential)]
        struct COMMTIMEOUTS
        {
            public uint ReadIntervalTimeout;
            public uint ReadTotalTimeoutMultiplier;
            public uint ReadTotalTimeoutConstant;
            public uint WriteTotalTimeoutMultiplier;
            public uint WriteTotalTimeoutConstant;
        }
 
        // Used to set the connection timeouts on our serial connection.
        [DllImport(&quot;kernel32.dll&quot;, SetLastError = true)]
        static extern bool SetCommTimeouts(IntPtr hFile, ref COMMTIMEOUTS lpCommTimeouts);
 
        // Used to read bytes from the serial connection.
        [DllImport(&quot;kernel32.dll&quot;)]
        static extern bool ReadFile(IntPtr hFile, byte[] lpBuffer,
           int nNumberOfBytesToRead, out int lpNumberOfBytesRead, int lpOverlapped);
 
        // Used to write bytes to the serial connection.
        [DllImport(&quot;kernel32.dll&quot;, SetLastError = true)]
        static extern bool WriteFile(IntPtr hFile, byte[] lpBuffer,
            int nNumberOfBytesToWrite, out int lpNumberOfBytesWritten, int lpOverlapped);
 
        // Used to flush the I/O buffers.
        [DllImport(&quot;kernel32.dll&quot;, SetLastError = true)]
        static extern bool PurgeComm(IntPtr hFile, int dwFlags);
 
        #endregion
    }
</pre>
<p></p></p>]]></description>
		<link>http://channel9.msdn.com/Forums/TechOff/528962-Stumbling-on-Basic-Serial-Port-IO/85ac7584bb1243d28c3a9deb000c31e4#85ac7584bb1243d28c3a9deb000c31e4</link>
		<pubDate>Mon, 15 Feb 2010 21:13:24 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/TechOff/528962-Stumbling-on-Basic-Serial-Port-IO/85ac7584bb1243d28c3a9deb000c31e4#85ac7584bb1243d28c3a9deb000c31e4</guid>
		<dc:creator>ploe</dc:creator>
		<slash:comments>7</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/ploe/Discussions/RSS</wfw:commentRss>
	</item>
	<item>
		<title>Tech Off - Stumbling on Basic Serial Port IO</title>
		<description><![CDATA[<p><blockquote><div class="quoteUser">ScanIAm said:</div><div class="quoteText">
<blockquote>
<div class="quoteUser">ManipUni said:</div>
<div class="quoteText">*snip*</div>
</blockquote>
<p>~7 years modem support in the early 90s <img src="http://ecn.channel9.msdn.com/o9/content/images/emoticons/emotion-1.gif" alt="Smiley"></p>
</div></blockquote>
<p>Thanks. I knew it was going to be something little. I appended the equivalent of '\r\n' to the command I was sending at it wrote back the command I sent plus the response. <img src='http://ecn.channel9.msdn.com/o9/content/images/emoticons/emotion-1.gif' alt='Smiley' /></p>
<p>&nbsp;</p>
<p>Edit: It was a GPRS/GSM device.</p></p>]]></description>
		<link>http://channel9.msdn.com/Forums/TechOff/528962-Stumbling-on-Basic-Serial-Port-IO/8ef3582768334ca09b449deb000c31a4#8ef3582768334ca09b449deb000c31a4</link>
		<pubDate>Mon, 15 Feb 2010 20:55:50 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/TechOff/528962-Stumbling-on-Basic-Serial-Port-IO/8ef3582768334ca09b449deb000c31a4#8ef3582768334ca09b449deb000c31a4</guid>
		<dc:creator>ploe</dc:creator>
		<slash:comments>7</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/ploe/Discussions/RSS</wfw:commentRss>
	</item>
	<item>
		<title>Tech Off - Stumbling on Basic Serial Port IO</title>
		<description><![CDATA[<p>I wrote a quick C# serial port wrapper class that uses the native APIs to communicate over serial (CreateFile, ReadFile, SetCommState, etc). Reading various posts online, it appears that alot of people have had problems with the .Net SerialPort class.</p>
<p>&nbsp;</p>
<p>Anyway, I feel like I'm missing some fundamental understanding of how serial communication works. When I send a command using WriteFile(), ReadFile() returns the exact command I sent instead of the response to my command. If I send &quot;AT&quot;, for example, my
 read returns &quot;AT&quot;. I feel like I'm not truly reading the devices response, but just what I wrote. <img src='http://ecn.channel9.msdn.com/o9/content/images/emoticons/emotion-6.gif' alt='Sad' />
</p>
<p>&nbsp;</p>
<p>So I thought I'd give the .Net SerialPort class a trying. I found this sample (<a href="http://msdn.microsoft.com/en-us/library/y2sxhat8.aspx">http://msdn.microsoft.com/en-us/library/y2sxhat8.aspx</a>), but when I run this it too just returns exactly what
 I sent instead of the device's response.</p>
<p>&nbsp;</p>
<p><font size="2">I know the device works because I can connect with it via Putty and I get the responses I expect. Can anyone point me in the right direction?</font></p>]]></description>
		<link>http://channel9.msdn.com/Forums/TechOff/528962-Stumbling-on-Basic-Serial-Port-IO/528962#528962</link>
		<pubDate>Mon, 15 Feb 2010 18:30:34 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/TechOff/528962-Stumbling-on-Basic-Serial-Port-IO/528962#528962</guid>
		<dc:creator>ploe</dc:creator>
		<slash:comments>7</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/ploe/Discussions/RSS</wfw:commentRss>
	</item>
	<item>
		<title>Tech Off - SQL Query...can&#39;t seem to wrap my head around this</title>
		<description><![CDATA[<p><blockquote><div class="quoteUser">Maddus Mattus said:</div><div class="quoteText">
<p>So if I understand correctly, you only want rows included that have a ten minute intersect?</p>
<p>&nbsp;</p>
<p>And if no rows are found you want a default selection?</p>
<p>&nbsp;</p>
<p>Then I would suggest you develop a cursor to fill a temp table and if the table has 0 rows, fire off another query,..</p>
<p>Then select the temp table as a resultset,..</p>
</div></blockquote>
<p>Yes, if a row overlaps a specified datetime, not only return that row, but all the rows that are in the 10-minute adjacent set this row belongs to.</p></p>]]></description>
		<link>http://channel9.msdn.com/Forums/TechOff/493362-SQL-Querycant-seem-to-wrap-my-head-around-this/c25017436eb4447993e39deb00090d94#c25017436eb4447993e39deb00090d94</link>
		<pubDate>Mon, 21 Sep 2009 21:11:04 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/TechOff/493362-SQL-Querycant-seem-to-wrap-my-head-around-this/c25017436eb4447993e39deb00090d94#c25017436eb4447993e39deb00090d94</guid>
		<dc:creator>ploe</dc:creator>
		<slash:comments>7</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/ploe/Discussions/RSS</wfw:commentRss>
	</item>
	<item>
		<title>Tech Off - SQL Query...can&#39;t seem to wrap my head around this</title>
		<description><![CDATA[<p>I feel like there exists a query that returns the data I'm looking for. I just can't seem to get my brain to tell me what it is <img src='http://ecn.channel9.msdn.com/o9/content/images/emoticons/emotion-4.gif' alt='Tongue Out' /> Perhaps I've been staring at it too long. Any help would be appreciated <img src='http://ecn.channel9.msdn.com/o9/content/images/emoticons/emotion-1.gif' alt='Smiley' /></p>
<p>&nbsp;</p>
<p>Let's say you have a table called WINDOW that has a START date, an&nbsp;END date and a unique ID.</p>
<p>&nbsp;</p>
<p>I want to select all the rows that are within 10 minutes of each other and at least one of the rows falls within a given datetime (which I pass in my query).</p>
<p>&nbsp;</p>
<p>Here's a sample dataset:</p>
<p>ID, START, END</p>
<p>1,&nbsp; 9/21/09 00:00:00,&nbsp; 9/21/09 00:30:00</p>
<p>2,&nbsp; 9/21/09 00:38:00,&nbsp; 9/21/09 02:00:00</p>
<p>3,&nbsp; 9/21/09 02:05:00,&nbsp; 9/21/09 04:00:00</p>
<p>4,&nbsp; 9/21/09 04:15:00,&nbsp; 9/21/09 04:30:00</p>
<p>5,&nbsp; 9/21/09 04:35:00,&nbsp; 9/21/09 07:30:00</p>
<p>&nbsp;</p>
<p>Rows 1 -&gt; 2 -&gt; 3 are a set because 2's START is only 8 minutes greater than 1's END and 3's START is only 5 greater than 2's END. Following that rule, 4 and 5 are a set as well.</p>
<p>&nbsp;</p>
<p>Passing in the datetime 9/21/09 02:00:00 should return rows 1, 2, and 3 because that time falls within the min and max time those 3 rows cover. If I were to pass in 9/21/09 04:20:00, I would expect rows 4 and 5 to be returned.</p>
<p>&nbsp;</p>
<p>I started with this query, but that's only going to return rows 2 and&nbsp;3&nbsp;(the immediately adjacent rows), not N rows.</p>
<p>SELECT * FROM WINDOW WHERE&nbsp;ABS(DATEDIFF(mi, END, '9/21/09 02:00:00')) &lt;= 10 OR ABS(DATEDIFF(mi, START, '9/21/09 02:00:00')) &lt;= 10</p>
<p>&nbsp;</p>
<p>And I tried another approach, but this will return rows 4 and 5 too&nbsp;when I only want 1, 2, and 3 <img src='http://ecn.channel9.msdn.com/o9/content/images/emoticons/emotion-6.gif' alt='Sad' /></p>
<p>SELECT * FROM WINDOW w WHERE EXISTS(SELECT TOP 1 ID FROM WINDOW w2 WHERE w2.ID != w.ID AND ABS(DATEDIFF(mi, w2.END, w.START)) &lt;= 10 OR ABS(DATEDIFF(mi, w2.START, w.END)) &lt;= 10)</p>
<p>&nbsp;</p>
<p>Grr</p>]]></description>
		<link>http://channel9.msdn.com/Forums/TechOff/493362-SQL-Querycant-seem-to-wrap-my-head-around-this/493362#493362</link>
		<pubDate>Mon, 21 Sep 2009 18:39:36 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/TechOff/493362-SQL-Querycant-seem-to-wrap-my-head-around-this/493362#493362</guid>
		<dc:creator>ploe</dc:creator>
		<slash:comments>7</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/ploe/Discussions/RSS</wfw:commentRss>
	</item>
	<item>
		<title>Tech Off - Label with transparent background in Windows Forms?</title>
		<description><![CDATA[<p>I needed to do this will a Panel. Maybe it'll work for a Label too...<br>
<br>
<p>protected override CreateParams CreateParams<br>
{<br>
&nbsp;&nbsp;&nbsp;&nbsp;get<br>
&nbsp;&nbsp;&nbsp;&nbsp;{<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CreateParams createParams = base.CreateParams;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (PaintMode == PanelPaintMode.Transparent)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;createParams.ExStyle |= 0x00000020; // WS_EX_TRANSPARENT<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return createParams;<br>
&nbsp;&nbsp;&nbsp;&nbsp;}<br>
}</p></p>]]></description>
		<link>http://channel9.msdn.com/Forums/TechOff/250991-Label-with-transparent-background-in-Windows-Forms/372d543854664ae8a10b9dea014f377a#372d543854664ae8a10b9dea014f377a</link>
		<pubDate>Thu, 07 May 2009 16:52:57 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/TechOff/250991-Label-with-transparent-background-in-Windows-Forms/372d543854664ae8a10b9dea014f377a#372d543854664ae8a10b9dea014f377a</guid>
		<dc:creator>ploe</dc:creator>
		<slash:comments>19</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/ploe/Discussions/RSS</wfw:commentRss>
	</item>
	<item>
		<title>Tech Off - Add form in another appdomain to mdi container</title>
		<description><![CDATA[<p>So I've been playing around with it a little...and I found setting the form's parent to the MdiClient's handle makes it a little less buggy.<br />SetParent(formHandle, MdiClient.Handle);<br /><br />#3 seems to no longer be a problem<br /><br />The maximize issue stated in #2 is somewhat remedied. When you maximize a plugin form it no longer maximizes over the menubar and toolbar but rather under it. Usually the behavior when you maximize a window is that the window's title is appended to the mdi
 parent's title. This does not happen when you maximize plugin forms.<br /><br />#1 is still an issue. For some reason, the title bars always appear inactive even if they are the front-most form.<br /><br />I've also noticed that tabbing to the next control doesn't work in plugin windows. Also control-tab to flip between windows is a little buggy.<br /><br />There's two approaches I can think of that may fix this. I could create my own MdiClient class so that it accounts for showing child windows via an instance of Form or a handle.
<br /><br />Another idea, and this seems like it's kind of a hack, is to:<br />1. Create a Form for each plugin<br />2. Copy the form style, title, and icon&nbsp;of the plugin window to the Form I newed up<br />3. Remove the style from the plugin window<br />4. Embed the plugin window's contents in the Form<br /><br />:/</p>]]></description>
		<link>http://channel9.msdn.com/Forums/TechOff/452844-Add-form-in-another-appdomain-to-mdi-container/bb35598fb3a6425bb6af9deb000321ad#bb35598fb3a6425bb6af9deb000321ad</link>
		<pubDate>Tue, 13 Jan 2009 14:38:31 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/TechOff/452844-Add-form-in-another-appdomain-to-mdi-container/bb35598fb3a6425bb6af9deb000321ad#bb35598fb3a6425bb6af9deb000321ad</guid>
		<dc:creator>ploe</dc:creator>
		<slash:comments>2</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/ploe/Discussions/RSS</wfw:commentRss>
	</item>
	<item>
		<title>Tech Off - Add form in another appdomain to mdi container</title>
		<description><![CDATA[<p>Our plugin model isolates plugins in their own AppDomain so that&nbsp;if a plugin crashes it doesn't take down our whole client app. This also allows for us to unload and load plugins if we choose to. The problem I've run into is now it's much harder to show
 my plugins (each have their own windows Form) in my main mdi window. <img src='http://ecn.channel9.msdn.com/o9/content/images/emoticons/emotion-6.gif' alt='Sad' /><br /><br />So I thought, why not pass the handle to the main window since I can pass primitives accross AppDomains? I then implemented a method in the main window where you pass in the plugin handle and it shows it in the main mdi window. Here's my code:<br /><br />uint style = GetWindowLongPtr(formHandle, GWL_STYLE);<br />style &amp;= ~WS_POPUP;<br />style = style | WS_CHILD | WS_VISIBLE;<br />SetWindowLong(formHandle, GWL_STYLE, style);<br />SetParent(formHandle, this.Handle);<br /><br />This approach seems to be buggy though...<br />1. The title bars of plugin windows always appear inactive as if the window was not in focus<br />2. When I maximize a plugin window, it does not seem to be aware that my main window has a menu and toolbar docked to the top. The maximized plugin window sits right over the top of them<br />3. And worst of all plugin windows are always on top of the other managed windows <img src='http://ecn.channel9.msdn.com/o9/content/images/emoticons/emotion-6.gif' alt='Sad' /></p>
<p>Has anyone successfully been able to get this working correctly? Or is there some other way I can do this?
<br /><br />It seems like a managed MdiClient is not aware of the native child windows that I've added...</p>]]></description>
		<link>http://channel9.msdn.com/Forums/TechOff/452844-Add-form-in-another-appdomain-to-mdi-container/452844#452844</link>
		<pubDate>Mon, 12 Jan 2009 19:34:20 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/TechOff/452844-Add-form-in-another-appdomain-to-mdi-container/452844#452844</guid>
		<dc:creator>ploe</dc:creator>
		<slash:comments>2</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/ploe/Discussions/RSS</wfw:commentRss>
	</item>
	<item>
		<title>Tech Off - Tell Windows that my program is responding</title>
		<description><![CDATA[<p><blockquote><div class="quoteUser">TommyCarlier said:</div><div class="quoteText">Console applications are not meant to be closed by the user. They don't have a message loop and should shut down when their task has been performed. </div></blockquote>
<p>This console app performs calculations that are particularly expensive. So I cache them in a hash_map. What I am doing is writing the hash_map to disk so that I can repopulate the cache when the app starts up again. I do also save the cache to disk once
 in a while just in case the app were to crash.<br /><br />I guess what I could do is increase the frequency to which I save the cache while the app is running, but&nbsp;I will lose any calculations between when I last saved and when I close the app.</p></p>]]></description>
		<link>http://channel9.msdn.com/Forums/TechOff/442789-Tell-Windows-that-my-program-is-responding/ffbcf87c5ad74e03897a9deb0001520c#ffbcf87c5ad74e03897a9deb0001520c</link>
		<pubDate>Thu, 13 Nov 2008 16:23:54 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/TechOff/442789-Tell-Windows-that-my-program-is-responding/ffbcf87c5ad74e03897a9deb0001520c#ffbcf87c5ad74e03897a9deb0001520c</guid>
		<dc:creator>ploe</dc:creator>
		<slash:comments>9</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/ploe/Discussions/RSS</wfw:commentRss>
	</item>
	<item>
		<title>Tech Off - Tell Windows that my program is responding</title>
		<description><![CDATA[<p>So I have this c&#43;&#43; console application that takes a while to close. In my SetConsoleCtrlHandler handler I have to write some things to disk before my program can closes. So when you close my application the End Program dialog comes up because Windows thinks
 my application is not responding. Is there a way for me to tell Windows &quot;hey I am still responding, it just takes me a while to close&quot;?</p>]]></description>
		<link>http://channel9.msdn.com/Forums/TechOff/442789-Tell-Windows-that-my-program-is-responding/442789#442789</link>
		<pubDate>Wed, 12 Nov 2008 21:41:25 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/TechOff/442789-Tell-Windows-that-my-program-is-responding/442789#442789</guid>
		<dc:creator>ploe</dc:creator>
		<slash:comments>9</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/ploe/Discussions/RSS</wfw:commentRss>
	</item>
	<item>
		<title>Tech Off - SQL IX lock</title>
		<description><![CDATA[<p>I have a SQL view that grabs data from various tables. One of those tables is table Y. The view is kinda slow and while the view is running I am unable to run any update statements on table Y. So I ran a stored procedure to view the current locks on the
 SQL server while the view is running. There was an IX lock on table Y. Now this view is only used to &quot;View&quot; data; why would the SQL server lock that table while it's running? Is there anything I can do to prevent this from happening? :/</p>]]></description>
		<link>http://channel9.msdn.com/Forums/TechOff/430548-SQL-IX-lock/430548#430548</link>
		<pubDate>Wed, 01 Oct 2008 00:45:44 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/TechOff/430548-SQL-IX-lock/430548#430548</guid>
		<dc:creator>ploe</dc:creator>
		<slash:comments>1</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/ploe/Discussions/RSS</wfw:commentRss>
	</item>
	<item>
		<title>Tech Off - Get stack trace of a ThreadPool Thread</title>
		<description><![CDATA[<p>I have a C# server application that's stuck in a loop somewhere; after a while the process just constantly uses 13% CPU (1 core). I'm pretty sure it's one of my ThreadPool threads that's doing this; some command sent by the client eventually triggers this
 infinite loop. <br /><br />I've looked at the StackTrace object as a stack trace would definately help me find the code that's causing this. There is a constructor that allows me to pass in a Thread object to get the stack trace of the passed in thread however I don't have a Thread object
 because it's a ThreadPool thread.<br /><br />Do you know any way that I can get a stack trace of a ThreadPool thread?<br /><br />I am able to identify the thread that is looping by printing out all the threads and finding the one that has taken up the most CPU time. However I can't seem to use the information from the code below&nbsp;to get a stack trace.<br /><br />foreach (System.Diagnostics.ProcessThread thread in System.Diagnostics.Process.GetCurrentProcess().Threads)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;Console.WriteLine(&quot;ID: {0}&quot;, thread.Id);<br />&nbsp;&nbsp;&nbsp;&nbsp;Console.WriteLine(&quot;Start Time: {0}&quot;, thread.StartTime);<br />&nbsp;&nbsp;&nbsp;&nbsp;Console.WriteLine(&quot;State: {0}&quot;, Enum.GetName(typeof(System.Diagnostics.ThreadState), thread.ThreadState));<br />&nbsp;&nbsp;&nbsp;&nbsp;Console.WriteLine(&quot;Total Proc Time: {0}\n&quot;, thread.TotalProcessorTime);<br />}<br /><br />Any suggestions? <img src='http://ecn.channel9.msdn.com/o9/content/images/emoticons/emotion-6.gif' alt='Sad' /></p>]]></description>
		<link>http://channel9.msdn.com/Forums/TechOff/420285-Get-stack-trace-of-a-ThreadPool-Thread/420285#420285</link>
		<pubDate>Thu, 07 Aug 2008 22:34:03 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/TechOff/420285-Get-stack-trace-of-a-ThreadPool-Thread/420285#420285</guid>
		<dc:creator>ploe</dc:creator>
		<slash:comments>3</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/ploe/Discussions/RSS</wfw:commentRss>
	</item>
	<item>
		<title>Tech Off - C# EventHandlers...</title>
		<description><![CDATA[<p>Is there a difference between these two lines?<br /><br />button.Click &#43;= new EventHandler(OnButtonClick);<br />button.Click &#43;= OnButtonClick;<br /><br />Both compile and work from what I can see. Do they behave differently? Is one preferred over the other?</p>]]></description>
		<link>http://channel9.msdn.com/Forums/TechOff/411816-C-EventHandlers/411816#411816</link>
		<pubDate>Wed, 25 Jun 2008 14:04:39 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/TechOff/411816-C-EventHandlers/411816#411816</guid>
		<dc:creator>ploe</dc:creator>
		<slash:comments>13</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/ploe/Discussions/RSS</wfw:commentRss>
	</item>
	<item>
		<title>Coffeehouse - what source control do you use mostly?</title>
		<description><![CDATA[<p></p>
<blockquote>
<div class="quoteAuthor">Custa1200 wrote:</div>
<div class="quoteBody">We use SVN via TortoiseSVN and ankhSVN inside of VS2003/2005. Works a treat.</div>
</blockquote>
<p></p>
<p>Ditto.</p>]]></description>
		<link>http://channel9.msdn.com/Forums/Coffeehouse/233128-what-source-control-do-you-use-mostly/73a76cbd5eb84d6da87c9deb011da98e#73a76cbd5eb84d6da87c9deb011da98e</link>
		<pubDate>Mon, 19 May 2008 23:37:28 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/Coffeehouse/233128-what-source-control-do-you-use-mostly/73a76cbd5eb84d6da87c9deb011da98e#73a76cbd5eb84d6da87c9deb011da98e</guid>
		<dc:creator>ploe</dc:creator>
		<slash:comments>38</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/ploe/Discussions/RSS</wfw:commentRss>
	</item>
	<item>
		<title>Tech Off - c++/cli xmldoc intellisense support?</title>
		<description><![CDATA[<p>I added the /doc switch; this generates the xdc files, but the documentation does not show up when you hover over members. Here's a bit of code. Perhaps this will clarify/expose the problem I am having.</p><p>/// &lt;summary&gt;Some comment&lt;/summary&gt;<br>public ref class Class1 {<br>public:<br>/// &lt;summary&gt;Creates a new instance of Class1&lt;/summary&gt;<br>Class1(void) {}<br>/// &lt;summary&gt;Does something&lt;/summary&gt;<br>/// &lt;returns&gt;Some integer&lt;/returns&gt;<br>int DoSomething() { return 0; }<br>};<br><br>None of the documentation above shows up when using Class1 in a C# project.</p>]]></description>
		<link>http://channel9.msdn.com/Forums/TechOff/260575-ccli-xmldoc-intellisense-support/470634bea47148818f979dfa00bd6e37#470634bea47148818f979dfa00bd6e37</link>
		<pubDate>Sun, 27 Jan 2008 20:25:41 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/TechOff/260575-ccli-xmldoc-intellisense-support/470634bea47148818f979dfa00bd6e37#470634bea47148818f979dfa00bd6e37</guid>
		<dc:creator>ploe</dc:creator>
		<slash:comments>5</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/ploe/Discussions/RSS</wfw:commentRss>
	</item>
</channel>
</rss>