<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="https://www.w3.org/2005/Atom" xmlns:sy="https://purl.org/rss/1.0/modules/syndication/" xmlns:dc="https://purl.org/dc/elements/1.1/" xmlns:content="https://purl.org/rss/1.0/modules/content/" xmlns:wfw="https://wellformedweb.org/CommentAPI/" xmlns:slash="https://purl.org/rss/1.0/modules/slash/"
  version="2.0">
  <channel>
    <title>Idle Coding</title>
    <atom:link
      href="https://docs.microsoft.com/archive/blogs/idle_coding/feed.xml"
      rel="self"
      type="application/rss+xml" />
    <link>https://docs.microsoft.com/archive/blogs/idle_coding/feed.xml</link>
    <description>Tidbits about coding for when you&amp;#039;re bored</description>
    <lastBuildDate>Tue, 16 Apr 2019 05:10:17 GMT</lastBuildDate>
    <language>en-US</language>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>1</sy:updateFrequency>
    <item>
      <title>Starting multiple applications on boot with a time delay</title>
      <link>https://docs.microsoft.com/archive/blogs/idle_coding/starting-multiple-applications-on-boot-with-a-time-delay</link>
      <pubDate>Tue, 12 Sep 2017 19:53:47 GMT</pubDate>
      <dc:creator><![CDATA[Ryan Knuth]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/idle_coding/?p=86</guid>
      <description><![CDATA[I recently moved to a new state away from my team's home office.  I will be permanently working from...]]></description>
      <content:encoded><![CDATA[I recently moved to a new state away from my team's home office.  I will be permanently working from home - using my home desktop as my main work station.  I can't code on my home desktop due to intellectual property concerns (this requires remoting into my work servers).  However, I can accomplish many of the non-development tasks; check email, response to code reviews, conduct meetings, write papers/drafts, etc.  As you can imagine, these tasks take many different applications than I normally use at home.  A short list of work-focused applications looks like:
<ul>
 	<li>Skype for Business</li>
 	<li>Microsoft Teams</li>
 	<li>Outlook</li>
 	<li>OneNote</li>
</ul>
I religiously trim the applications that get startup privileges on my home desktop.  I want it to boot quickly and be ready to go within 20 seconds.  However, I've also noticed that I forget to launch important applications like Skype and Outlook if they're not launched at boot.  This has caused me to miss important meetings - woops.

Thus, I created a delayed task in the task scheduler to run at boot.  On my first attempt at this, I added all the programs I wanted to delay launch to the actions tab.  However, I noticed that only the first application was ever launch.  I have no idea why it didn't launch the other applications but we can get around this by using a batch file.

These steps were done on Windows 10.
<ol>
 	<li>Find a location for your script/batch file.  Your documents library is a good place.</li>
 	<li>Create a new file and name it something like "StartApplications.bat". The most important thing is to make sure the extension of the file is ".bat" - you may need to make extension visible in order to do this.</li>
 	<li>Right-click the file and select "edit"</li>
 	<li>For each application you want to start, add a start command on a new line in the batch file.
<ol>
 	<li>Type <em>start "" &lt;path to application&gt;</em></li>
 	<li>Replace <em>&lt;path to application&gt; </em>with an actual path</li>
 	<li>Example: start "" "C:\Program Files\Microsoft Office\root\Office16\OUTLOOK.EXE"</li>
</ol>
</li>
 	<li>Save the file</li>
 	<li>Hit the windows key and type "task"</li>
 	<li>Task scheduler should be the "best match" - hit enter</li>
 	<li>In the "Actions" pane on the right side, click "Create Task"</li>
 	<li>Enter a name e.g. "Start Applications"</li>
 	<li>Click on the "triggers" tab</li>
 	<li>Click the "new" button</li>
 	<li>Click the "begin the task" drop down and select "at log on"</li>
 	<li>Check "delay task for" and select a desired time. I used one minute.</li>
 	<li>Click "Ok"</li>
 	<li>Click the "actions" tab and click "new"</li>
 	<li>Click "browse" and navigate to your batch file you created</li>
 	<li>Click "ok"</li>
 	<li>Click "ok"</li>
</ol>
Restart your computer and see if your applications launch successfully!

&nbsp;]]></content:encoded>
    </item>
    <item>
      <title>Why delete[] matters</title>
      <link>https://docs.microsoft.com/archive/blogs/idle_coding/why-delete-matters</link>
      <pubDate>Mon, 17 Aug 2015 13:12:36 GMT</pubDate>
      <dc:creator><![CDATA[Ryan Knuth]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/idle_coding/2015/08/17/why-delete-matters/</guid>
      <description><![CDATA[Even as&nbsp;a senior software engineer, it seems like I still learn every day.&nbsp; This is a...]]></description>
      <content:encoded><![CDATA[<p>Even as&nbsp;a senior software engineer, it seems like I still learn every day.&nbsp; This is a small story about what I learned today.</p>
<p>Office is an enormous collection of source code.&nbsp; I have just about every data structure imaginable right at my fingertips.&nbsp; Smart pointers, smart array handling, hashes, sets, and every other collection type.&nbsp; Needless to say, I rarely every write a line of code that looks something like:</p>
<pre class="scroll"><code class="cplusplus">MyClass* pClasses = new MyClass[ 10 ];</code></pre>
<p>It will always be wrapped in something like:</p>
<pre class="scroll"><code class="cplusplus">MyArrayHolder&lt; MyClass &gt; classArray( 10 );</code></pre>
<p>STL provides similar functionality:</p>
<pre class="scroll"><code class="cplusplus">std::vector&lt; MyClass &gt; classVector( 10 );</code></pre>
<p>These classes call new[] and delete[] for us.&nbsp; A side effect of delete[] is that it calls the destructor (if destructible) on every object in the allocation.&nbsp; Something like this:</p>
<pre class="scroll"><code class="cplusplus">MyClass* pClasses = new MyClass[ 10 ];<br />... Properly setup all 10 allocations ...<br />delete[] pClasses;</code></pre>
<p>will lead to ~MyClass() getting called 10 times, one for each MyClass chunk in the array allocation.&nbsp; How does it know?&nbsp; Calling new[]&nbsp;puts a nice "count" variable at the beginning of the allocation (again, if it is destructible):</p>
<pre class="scroll"><code class="cplusplus">[count | MyClass1 | MyClass2 | MyClass3 | ... | MyClass10]</code></pre>
<p>When new[] returns, it gives you a pointer to the start of MyClass1, not count.&nbsp; On my 64-bit OS, count of 8 bytes which seems pretty reasonable.&nbsp; Furthermore, delete[] is pretty smart.&nbsp; You pass it the pointer to the beginning of MyClass1 and it will say, "Oh, this is destructible. That means I have a piece of memory allocated for the count at the beginning.&nbsp; I need to delete that too!" And so, it adjusts the pointer appropriately and deletes the entire block.</p>
<p>As long as you don't do anything "strange", your collection data structure will handle calling new[] and delete[] on your objects.&nbsp; Let's look at something strange, though.&nbsp; There are cases when we don't actually want the destructor called on some of the MyClass allocations.&nbsp; Let's say that we didn't fill them all in and they're left with garbage memory.&nbsp; Calling a destructor on garbage memory is undefined behavior - aka crash incoming.&nbsp; To handle this, we do everything in BYTEs.&nbsp; This is completely valid:</p>
<p><code class="cplusplus">BYTE* pBytes = new BYTE[sizeof(MyClass)];<br />MyClass* pMyClass = static_cast&lt;MyClass&gt;(pBytes);</code></p>
<p>By extension, you could imagine using this to allocate a large number of bytes to form a MyClass array.&nbsp; The important thing to note here is that BYTE is <span style="text-decoration: underline;">not</span> a destructible object.&nbsp; There is no ~BYTE to call.&nbsp; The allocator sees this so the memory allocation looks like this:</p>
<p><code class="cplusplus">[BYTE1 | BYTE2 | BYTE3 | ... | BYTE_N]</code></p>
<p>There is no need to store the count because there's no destructors to call.&nbsp; This is where the gotchas come in.&nbsp; Imagine I then did something like this:</p>
<p><code class="cplusplus">BYTE* pBytes = new BYTE[sizeof(MyClass)];<br /> MyClass* pMyClass = static_cast&lt;MyClass&gt;(pBytes);</code></p>
<p><code class="cplusplus">... tons of code, losing track of memory allocations ...<br />delete[] pMyClass;</code></p>
<p>What is the allocator going to do there?&nbsp; I'm calling delete on MyClass which is destructible.&nbsp; The pointer will get adjusted and, uh oh.&nbsp; The pointer should not have been adjusted.&nbsp; In my scenario, the allocator started yelling at me which is a bit scary.&nbsp; It wasn't until a vastly more experience developer than I came and helped me debug this that we found my error.&nbsp; He kindly described how new[] and delete[] worked with destructible objects and the world was saved.</p>]]></content:encoded>
    </item>
    <item>
      <title>Surface Pro 3 Bluetooth Driver Fix</title>
      <link>https://docs.microsoft.com/archive/blogs/idle_coding/surface-pro-3-bluetooth-driver-fix</link>
      <pubDate>Wed, 08 Oct 2014 20:05:00 GMT</pubDate>
      <dc:creator><![CDATA[Ryan Knuth]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/idle_coding/2014/10/08/surface-pro-3-bluetooth-driver-fix/</guid>
      <description><![CDATA[I recently bought my wife a Surface Pro 3 that replaced her old and dying MacBook Pro.&nbsp;...]]></description>
      <content:encoded><![CDATA[<p>I recently bought my wife a Surface Pro 3 that replaced her old and dying MacBook Pro.&nbsp; Unfortunately, she has experienced the same WiFi and Bluetooth connectivity problems as everyone else.&nbsp; Obviously, this is quite embarrassing coming from someone who works for Microsoft and convinced a long time Apple product user to switch.&nbsp; Thus, I spend quite a bit of time fixing her computer so that it behaves appropriately.</p>
<p>Last night, her Bluetooth just stopped working.&nbsp; When I went into device manager, there was no Bluetooth device to be seen.&nbsp; Under <strong><em>Other Devices</em></strong>&nbsp; I saw something like "Bluetooth and WLAN adapter".&nbsp; After uninstalling the device drivers like every good Windows users knows how to do, I clicked "Update Drivers."&nbsp; Unfortunately, I was met with "This device is not configured correctly. (code 1)."&nbsp; I opened up the properties page for said device and it revealed that drivers were missing for the device.&nbsp;</p>
<p>Admittedly, I was stumped.&nbsp; I had never had to do anything additional for the plethora of Windows devices I have used or maintained over the years.&nbsp; I downloaded the Surface Pro 3 driver pack from the Microsoft website.&nbsp; I navigated to the Marvell\bt folder, right-clicked the INF file, and clicked "Install."&nbsp; I went back to device manager, selected "update drivers", and manually selected the Marvell AVASTAR drivers I just installed.&nbsp; Even this didn't work.&nbsp; Now, I'm completely stumped.</p>
<p>However, it dawned on me as I searched the web for solutions to this problem that devices support a variety of drivers.&nbsp; This is why BIOS can be shown on your high-tech monitor even though it hasn't loaded the more advanced drivers.&nbsp; Your monitor supports some type of standard monitor drivers that everyone knows.&nbsp; I don't know the specifics but I bet the functionality is quite simple but it succeeds in at least showing something on the screen.&nbsp; Luckily, there is something similar to this for Bluetooth devices.</p>
<p>Enter the "Generic Bluetooth Driver."&nbsp; Any respectable Bluetooth device would support such a driver with basic functionality.&nbsp; I used this driver and it worked!&nbsp; Here's how:</p>
<ol>
<li>Hit the windows key to get to the Win8 start screen</li>
<li>Type "Device manager" and hit enter when it shows up in the search panel</li>
<li>Find your Bluetooth device</li>
<ol>
<li>It may still have the bad drivers in use.&nbsp; It would then be found under "Bluetooth".&nbsp; Right-click every item under that node and select uninstall.&nbsp; (DO NOT SELECT DELETE)</li>
<li>If you already uninstalled the drivers, you will most likely find the device under "Other devices"</li>
</ol>
<li>Right-click the Bluetooth device and select "Update drivers"</li>
<li>Select "Browse my computer for driver software"</li>
<li>Select "Let me pick from a list of device drivers on my computer"</li>
<li>Select "Bluetooth" and hit next</li>
<li>Select "GenericAdapter" under Manufacturer</li>
<li>Select "Generic Bluetooth Adapter" under Model</li>
<li>Click next until it has installed the drivers</li>
</ol>
<p>This should fix your problem!</p>
<p>&nbsp;</p>]]></content:encoded>
    </item>
    <item>
      <title>Fiber/Thread Local Storage</title>
      <link>https://docs.microsoft.com/archive/blogs/idle_coding/fiberthread-local-storage</link>
      <pubDate>Thu, 11 Jul 2013 09:35:00 GMT</pubDate>
      <dc:creator><![CDATA[Ryan Knuth]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/idle_coding/2013/07/11/fiberthread-local-storage/</guid>
      <description><![CDATA[Over the course of professional development you run into extremely helpful functions in the Windows...]]></description>
      <content:encoded><![CDATA[<p>Over the course of professional development you run into extremely helpful functions in the Windows API.&nbsp; Today I ran into a set of functions that allow for storing a value specific to each thread.&nbsp;&nbsp;See the following link for a description of how to use thread local storage.</p>
<p><a href="https://msdn.microsoft.com/en-us/library/windows/desktop/ms686991(v=vs.85).aspx">https://msdn.microsoft.com/en-us/library/windows/desktop/ms686991(v=vs.85).aspx</a></p>
<p>Note that a fiber runs in the context of the scheduling&nbsp;thread.&nbsp; Each thread may have multiple fibers and each fiber may have its own local storage.&nbsp; If a thread only has one fiber, then thread and fiber local storages are identical.&nbsp; For more information about fibers:</p>
<p><a href="https://msdn.microsoft.com/en-us/library/windows/desktop/ms682661(v=vs.85).aspx">https://msdn.microsoft.com/en-us/library/windows/desktop/ms682661(v=vs.85).aspx</a></p>
<p>Now, to the more interesting part, using the APIs.&nbsp; Luckily, using the local storage is straight forward.</p>
<p>Process for using a local storage:</p>
<ol>
<li>Initialize local storage to retrieve index using TlsAlloc()</li>
<li>Set values in local storage using TlsSetValue()</li>
<li>Retrieve values using TlsGetValue()</li>
</ol>
<p>Allocate the thread local storage once for all threads.&nbsp; Each thread uses the same index to set and retrieve values.</p>
<p>The first MSDN link has a great explanation on thread local storage.</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>]]></content:encoded>
    </item>
    <item>
      <title>Using registers for return value debugging in Visual Studio</title>
      <link>https://docs.microsoft.com/archive/blogs/idle_coding/using-registers-for-return-value-debugging-in-visual-studio</link>
      <pubDate>Fri, 13 Jul 2012 09:20:00 GMT</pubDate>
      <dc:creator><![CDATA[Ryan Knuth]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/idle_coding/2012/07/13/using-registers-for-return-value-debugging-in-visual-studio/</guid>
      <description><![CDATA[Often, I find myself desiring to know the return value of function. &nbsp;Normally, I can set a...]]></description>
      <content:encoded><![CDATA[<p>Often, I find myself desiring to know the return value of function. &nbsp;Normally, I can set a print message breakpoint on the following line after the function call:</p>
<pre style="background: white; color: black; font-family: Consolas;"><span style="color: blue;">bool</span>&nbsp;fFlag&nbsp;=&nbsp;pMyClass-&gt;FGetSomeFlag();
<span style="color: blue;">if</span>(&nbsp;fFlag&nbsp;)&nbsp;&nbsp;<span style="color: green;">//&nbsp;&lt;--&nbsp;Set&nbsp;breakpoint&nbsp;here</span>
&nbsp;&nbsp;DoSomething(&nbsp;pMyClass&nbsp;);</pre>
<p>However, this doesn't work in all cases.&nbsp;&nbsp;Suppose we want to know what the system call to ::GetTickCount() returns. &nbsp;We don't have a variable to output and calling the function in the debugger (if it were even possible) would return inaccurate values. &nbsp;We can use our handy registers to output the value of GetTickCount(). &nbsp;We know that the return value will be stuffed into the EAX (32bit) and RAX (64bit) registers. &nbsp;Note, you can usually get away with using EAX on 64bit machines. &nbsp;But, it's handy to know that the full 64bit value is in RAX. &nbsp;Let's look at a little program to illustrate:</p>
<pre style="background: white; color: black; font-family: Consolas;">DWORD&nbsp;GetCurrentTickCount()
{
&nbsp;&nbsp;&nbsp;<span style="color: blue;">return</span>&nbsp;::GetTickCount();
}&nbsp;<span style="color: green;">//&nbsp;&lt;--&nbsp;Set&nbsp;when-hit&nbsp;breakpoint&nbsp;here&nbsp;with:</span>
&nbsp;&nbsp;<span style="color: green;">//&nbsp;TickCount32:&nbsp;{EAX}&nbsp;TickCount64:&nbsp;{RAX}</span>
&nbsp;
<span style="color: blue;">bool</span>&nbsp;FOddTickCount()
{
&nbsp;&nbsp;&nbsp;<span style="color: blue;">return</span>&nbsp;GetCurrentTickCount()&nbsp;&amp;&nbsp;<span style="color: maroon;">1</span>;
}
 
<span style="color: blue;">void</span>&nbsp;main()
{
&nbsp;&nbsp;&nbsp;<span style="color: blue;">for</span>(&nbsp;<span style="color: blue;">int</span>&nbsp;i&nbsp;=&nbsp;<span style="color: maroon;">0</span>;&nbsp;i&nbsp;&lt;&nbsp;<span style="color: maroon;">10</span>;&nbsp;i++&nbsp;)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue;">bool</span>&nbsp;fOdd&nbsp;=&nbsp;FOddTickCount();
 
&nbsp;&nbsp;&nbsp;<span style="color: blue;">return</span>;
}</pre>
<p>If you look at the assembly, you see that the debugger has the ability to set a breakpoint after the call to GetTickCount():</p>
<pre style="background: white; color: black; font-family: Consolas;">&nbsp;&nbsp;&nbsp;<span style="color: blue;">return</span>&nbsp;::GetTickCount();
<span style="color: maroon;">000000013FDF1045</span>&nbsp;&nbsp;call&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;qword&nbsp;ptr&nbsp;[__imp_GetTickCount&nbsp;(<span style="color: maroon;">13FDFB300h</span>)]&nbsp;&nbsp;
}&nbsp;<span style="color: green;">//&nbsp;&lt;--&nbsp;Set&nbsp;when-hit&nbsp;breakpoint&nbsp;here&nbsp;with:</span>
<span style="color: maroon;">000000013FDF104B</span>&nbsp;&nbsp;add&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;rsp,<span style="color: maroon;">20h</span>&nbsp;&nbsp;
<span style="color: maroon;">000000013FDF104F</span>&nbsp;&nbsp;pop&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;rdi&nbsp;&nbsp;
<span style="color: maroon;">000000013FDF1050</span>&nbsp;&nbsp;ret&nbsp;&nbsp;</pre>
<p>This allows us to set breakpoints after functions are called with return values.&nbsp; When I run the small program, my debugging output window looks like:</p>
<pre style="background: white; color: black; font-family: Consolas;">TickCount32:&nbsp;<span style="color: maroon;">355088539</span>&nbsp;TickCount64:&nbsp;<span style="color: maroon;">355088539</span>
TickCount32:&nbsp;<span style="color: maroon;">355088602</span>&nbsp;TickCount64:&nbsp;<span style="color: maroon;">355088602</span>
TickCount32:&nbsp;<span style="color: maroon;">355088664</span>&nbsp;TickCount64:&nbsp;<span style="color: maroon;">355088664</span>
TickCount32:&nbsp;<span style="color: maroon;">355088726</span>&nbsp;TickCount64:&nbsp;<span style="color: maroon;">355088726</span>
TickCount32:&nbsp;<span style="color: maroon;">355088789</span>&nbsp;TickCount64:&nbsp;<span style="color: maroon;">355088789</span>
TickCount32:&nbsp;<span style="color: maroon;">355088851</span>&nbsp;TickCount64:&nbsp;<span style="color: maroon;">355088851</span>
TickCount32:&nbsp;<span style="color: maroon;">355088914</span>&nbsp;TickCount64:&nbsp;<span style="color: maroon;">355088914</span>
TickCount32:&nbsp;<span style="color: maroon;">355088976</span>&nbsp;TickCount64:&nbsp;<span style="color: maroon;">355088976</span>
TickCount32:&nbsp;<span style="color: maroon;">355089038</span>&nbsp;TickCount64:&nbsp;<span style="color: maroon;">355089038</span>
TickCount32:&nbsp;<span style="color: maroon;">355089101</span>&nbsp;TickCount64:&nbsp;<span style="color: maroon;">355089101</span></pre>
<p>I use this technique quite a bit, hopefully it helps.</p>]]></content:encoded>
    </item>
    <item>
      <title>My first mistake</title>
      <link>https://docs.microsoft.com/archive/blogs/idle_coding/my-first-mistake</link>
      <pubDate>Wed, 11 Jul 2012 20:05:15 GMT</pubDate>
      <dc:creator><![CDATA[Ryan Knuth]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/idle_coding/2012/07/11/my-first-mistake/</guid>
      <description><![CDATA[I first started at PowerPoint during the lengthy bug fixing stage. &nbsp;It was being thrown into a...]]></description>
      <content:encoded><![CDATA[<p>I first started at PowerPoint during the lengthy bug fixing stage. &nbsp;It was being thrown into a completely new environment, attempting to&nbsp;decipher&nbsp;another person's code and the C++ was fathoms more advanced than anything I had ever seen. &nbsp;I don't know if other new hires have had the same experience but I felt like I got hit in the face with a newspaper.</p>
<p>Needless to say, I did check-in fixes and aided in lowering our bug count. &nbsp;However, one fix wasn't done absolutely perfectly. &nbsp;I don't remember the bug or the fix but I do remember the outcome. &nbsp;It included something like:</p>
<pre class="scroll"><code class="cplusplus">MyPointerClass* pMyClass = GetMyPointerClass();<br />pMyClass-&gt;DoSomething();</code></pre>
<p>My boss walked into my office with laptop on hand and a completely stern looking upon his face (he normally looks very calm and quiet). &nbsp;Immediately, I felt my face go flush as I knew I was in trouble. &nbsp;He pointed me to the bug I fixed and the code that I had changed. &nbsp;He looked at me and said "You remember this?" &nbsp;After acknowledging, he went on to explain that crash that I had caused. &nbsp;If my face wasn't tomato red, it was now. &nbsp;A null-pointer crash. &nbsp;I learned how to avoid that in CS101. &nbsp;What a stupid mistake! &nbsp;He must have seen my embarrassment as he left my office say something like "it's ok this time, just remember for next time."</p>
<p>Lesson learned, everyone. &nbsp;CHECK YOUR POINTERS!</p>]]></content:encoded>
    </item>
    <item>
      <title>Editing controls within an ItemContainer for a ListBox (Silverlight/Windows Phone)</title>
      <link>https://docs.microsoft.com/archive/blogs/idle_coding/editing-controls-within-an-itemcontainer-for-a-listbox-silverlightwindows-phone</link>
      <pubDate>Tue, 10 Jul 2012 10:14:00 GMT</pubDate>
      <dc:creator><![CDATA[Ryan Knuth]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/idle_coding/2012/07/10/editing-controls-within-an-itemcontainer-for-a-listbox-silverlightwindows-phone/</guid>
      <description><![CDATA[Normally, we place controls on a page, give them names, and edit their contents in the respective...]]></description>
      <content:encoded><![CDATA[<p>Normally, we place controls on a page, give them names, and edit their contents in the respective code file. &nbsp;However, what happens if those controls live in an ItemTemplate for the ListBox? &nbsp;We can easily bind a DataSource to the ListBox and access the data from there. &nbsp;But, that doesn't solve 100% of the cases. &nbsp;What happens if we want to bind to something that's not our DataSource - say the state of IsSelected on the ListBox? &nbsp;In WPF, we can bind to IsSelected using a RelativeSource=FindAncestor. &nbsp;Unfortunately, that doesn't exist in SilverLight and the Windows Phone SDK. &nbsp;We must be a bit more creative in our approach.</p>
<p>Enter our scenario. &nbsp;Say we have a ListBox filled with movie titles. &nbsp;We bind our ListBox's DataContext to an ObservableCollection&lt;MovieItem&gt;. &nbsp;We bind the title of the movie to the TextBlock in our ItemTemplate. &nbsp;When our app boots, we load some fake movie data into our collection and our ListBox is automatically updated.</p>
<p>CODE:</p>
<pre style="background: white; color: black; font-family: Consolas;"><span style="color: blue;">public</span>&nbsp;<span style="color: blue;">partial</span>&nbsp;<span style="color: blue;">class</span>&nbsp;<span style="color: #2b91af;">MainPage</span>&nbsp;:&nbsp;PhoneApplicationPage
{
&nbsp;&nbsp;&nbsp;<span style="color: blue;">public</span>&nbsp;MainPage()
&nbsp;&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;InitializeComponent();
 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: green;">//&nbsp;Create&nbsp;movie&nbsp;items</span>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue;">for</span>(&nbsp;<span style="color: blue;">int</span>&nbsp;i&nbsp;=&nbsp;<span style="color: maroon;">1</span>;&nbsp;i&nbsp;&lt;=&nbsp;<span style="color: maroon;">10</span>;&nbsp;i++&nbsp;)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;m_movieList.Add(&nbsp;<span style="color: blue;">new</span>&nbsp;<span style="color: #2b91af;">MovieItem</span>()
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Title&nbsp;=&nbsp;<span style="color: #a31515;">"Saw&nbsp;"</span>&nbsp;+&nbsp;i,
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Description&nbsp;=&nbsp;<span style="color: #a31515;">"This&nbsp;is&nbsp;a&nbsp;long&nbsp;description&nbsp;so&nbsp;that&nbsp;we&nbsp;can&nbsp;see&nbsp;it&nbsp;in&nbsp;the&nbsp;drop&nbsp;down&nbsp;menu.&nbsp;Sorry,&nbsp;I&nbsp;don't&nbsp;have&nbsp;anything&nbsp;better&nbsp;to&nbsp;say."</span>,
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Duration&nbsp;=&nbsp;<span style="color: #2b91af;">TimeSpan</span>.FromHours(&nbsp;<span style="color: maroon;">2</span>&nbsp;)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;);
 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;MovieListBox.DataContext&nbsp;=&nbsp;m_movieList;
&nbsp;&nbsp;&nbsp;}
 
&nbsp;&nbsp;&nbsp;<span style="color: #2b91af;">MovieItemList</span>&nbsp;m_movieList&nbsp;=&nbsp;<span style="color: blue;">new</span>&nbsp;<span style="color: #2b91af;">MovieItemList</span>();
}
 
<span style="color: blue;">public</span>&nbsp;<span style="color: blue;">class</span>&nbsp;<span style="color: #2b91af;">MovieItemList</span>&nbsp;:&nbsp;<span style="color: #2b91af;">ObservableCollection</span>&lt;<span style="color: #2b91af;">MovieItem</span>&gt;&nbsp;{&nbsp;}
 
<span style="color: blue;">public</span>&nbsp;<span style="color: blue;">class</span>&nbsp;<span style="color: #2b91af;">MovieItem</span>
{
&nbsp;&nbsp;&nbsp;<span style="color: blue;">public</span>&nbsp;<span style="color: blue;">string</span>&nbsp;Title&nbsp;{&nbsp;<span style="color: blue;">get</span>;&nbsp;<span style="color: blue;">set</span>;&nbsp;}
&nbsp;&nbsp;&nbsp;<span style="color: blue;">public</span>&nbsp;<span style="color: blue;">string</span>&nbsp;Description&nbsp;{&nbsp;<span style="color: blue;">get</span>;&nbsp;<span style="color: blue;">set</span>;&nbsp;}
&nbsp;&nbsp;&nbsp;<span style="color: blue;">public</span>&nbsp;<span style="color: #2b91af;">TimeSpan</span>&nbsp;Duration&nbsp;{&nbsp;<span style="color: blue;">get</span>;&nbsp;<span style="color: blue;">set</span>;&nbsp;}
}</pre>
<p>XAML:</p>
<pre style="background: white; color: black; font-family: Consolas;"><span style="color: blue;">&lt;</span><span style="color: #a31515;">phone</span><span style="color: blue;">:</span><span style="color: #a31515;">PhoneApplicationPage.Resources</span><span style="color: blue;">&gt;</span>
<span style="color: #a31515;">&nbsp;&nbsp;&nbsp;</span><span style="color: blue;">&lt;</span><span style="color: #a31515;">local</span><span style="color: blue;">:</span><span style="color: #a31515;">MovieItemList</span><span style="color: red;">&nbsp;x</span><span style="color: blue;">:</span><span style="color: red;">Key</span><span style="color: blue;">=</span><span style="color: blue;">"MovieItemListDataSource"</span><span style="color: red;">&nbsp;d</span><span style="color: blue;">:</span><span style="color: red;">IsDataSource</span><span style="color: blue;">=</span><span style="color: blue;">"True"</span><span style="color: blue;">/&gt;</span>
<span style="color: blue;">&lt;/</span><span style="color: #a31515;">phone</span><span style="color: blue;">:</span><span style="color: #a31515;">PhoneApplicationPage.Resources</span><span style="color: blue;">&gt;</span></pre>
<pre style="background: white; color: black; font-family: Consolas;"><span style="color: blue;">...</span></pre>
<pre style="background: white; color: black; font-family: Consolas;"><span style="color: blue;">&lt;</span><span style="color: #a31515;">ListBox</span><span style="color: red;">&nbsp;x</span><span style="color: blue;">:</span><span style="color: red;">Name</span><span style="color: blue;">=</span><span style="color: blue;">"MovieListBox"</span><span style="color: red;">&nbsp;DataContext</span><span style="color: blue;">="{</span><span style="color: #a31515;">Binding</span><span style="color: red;">&nbsp;Source</span><span style="color: blue;">={</span><span style="color: #a31515;">StaticResource</span><span style="color: red;">&nbsp;MovieItemListDataSource</span><span style="color: blue;">}}</span><span style="color: blue;">"</span><span style="color: red;">&nbsp;ItemsSource</span><span style="color: blue;">="{</span><span style="color: #a31515;">Binding</span><span style="color: blue;">}</span><span style="color: blue;">"</span><span style="color: blue;">&gt;</span>
<span style="color: #a31515;">&nbsp;&nbsp;&nbsp;</span><span style="color: blue;">&lt;</span><span style="color: #a31515;">ListBox.Resources</span><span style="color: blue;">&gt;</span>
<span style="color: #a31515;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: blue;">&lt;</span><span style="color: #a31515;">DataTemplate</span><span style="color: red;">&nbsp;x</span><span style="color: blue;">:</span><span style="color: red;">Key</span><span style="color: blue;">=</span><span style="color: blue;">"DataTemplateMovie"</span><span style="color: blue;">&gt;</span>
<span style="color: #a31515;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: blue;">&lt;</span><span style="color: #a31515;">StackPanel</span><span style="color: blue;">&gt;</span>
<span style="color: #a31515;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: blue;">&lt;</span><span style="color: #a31515;">TextBlock</span><span style="color: red;">&nbsp;TextWrapping</span><span style="color: blue;">=</span><span style="color: blue;">"Wrap"</span><span style="color: red;">&nbsp;Text</span><span style="color: blue;">="{</span><span style="color: #a31515;">Binding</span><span style="color: red;">&nbsp;Title</span><span style="color: blue;">}</span><span style="color: blue;">"</span><span style="color: red;">&nbsp;VerticalAlignment</span><span style="color: blue;">=</span><span style="color: blue;">"Top"</span><span style="color: red;">&nbsp;HorizontalAlignment</span><span style="color: blue;">=</span><span style="color: blue;">"Left"</span><span style="color: blue;">/&gt;</span>
<span style="color: #a31515;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: blue;">&lt;/</span><span style="color: #a31515;">StackPanel</span><span style="color: blue;">&gt;</span>
<span style="color: #a31515;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: blue;">&lt;/</span><span style="color: #a31515;">DataTemplate</span><span style="color: blue;">&gt;</span>
<span style="color: #a31515;">&nbsp;&nbsp;&nbsp;</span><span style="color: blue;">&lt;/</span><span style="color: #a31515;">ListBox.Resources</span><span style="color: blue;">&gt;</span>
<span style="color: #a31515;">&nbsp;&nbsp;&nbsp;</span><span style="color: blue;">&lt;</span><span style="color: #a31515;">ListBox.ItemTemplate</span><span style="color: blue;">&gt;</span>
<span style="color: #a31515;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: blue;">&lt;</span><span style="color: #a31515;">StaticResource</span><span style="color: red;">&nbsp;ResourceKey</span><span style="color: blue;">=</span><span style="color: blue;">"DataTemplateMovie"</span><span style="color: blue;">/&gt;</span>
<span style="color: #a31515;">&nbsp;&nbsp;&nbsp;</span><span style="color: blue;">&lt;/</span><span style="color: #a31515;">ListBox.ItemTemplate</span><span style="color: blue;">&gt;</span>
<span style="color: blue;">&lt;/</span><span style="color: #a31515;">ListBox</span><span style="color: blue;">&gt;</span></pre>
<p>This works great. &nbsp;However, we want to add some advanced functionality. &nbsp;When an item in the ListBox is selected, we want to drop down a Panel that displays additional information like run-time and a description. &nbsp;This means we need to know which ListBoxItem is selected. &nbsp;We don't have the ability to use FindAncestor since we're in SilverLight. &nbsp;This is where we get a bit creative. &nbsp;First, we need to add what we'll call a drop down panel to our ItemTemplate. &nbsp;We place an invisible StackPanel with two TextBlocks for the run-time and description. &nbsp;When it is invisible, it does not take up any space in our ItemTemplate. &nbsp;When we turn it visible, the ItemTemplate will grow and act just like a drop down menu.</p>
<p>XAML (add as a child of the title TextBlock):</p>
<pre style="background: white; color: black; font-family: Consolas;"><span style="color: blue;">&lt;</span><span style="color: #a31515;">StackPanel</span><span style="color: red;">&nbsp;x</span><span style="color: blue;">:</span><span style="color: red;">Name</span><span style="color: blue;">=</span><span style="color: blue;">"DropDownPanel"</span><span style="color: red;">&nbsp;Margin</span><span style="color: blue;">=</span><span style="color: blue;">"20,0,0,0"</span><span style="color: red;">&nbsp;Visibility</span><span style="color: blue;">=</span><span style="color: blue;">"Collapsed"</span><span style="color: blue;">&gt;</span>
<span style="color: #a31515;">&nbsp;&nbsp;&nbsp;</span><span style="color: blue;">&lt;</span><span style="color: #a31515;">TextBlock</span><span style="color: red;">&nbsp;Margin</span><span style="color: blue;">=</span><span style="color: blue;">"0"</span><span style="color: red;">&nbsp;TextWrapping</span><span style="color: blue;">=</span><span style="color: blue;">"Wrap"</span><span style="color: red;">&nbsp;Text</span><span style="color: blue;">="{</span><span style="color: #a31515;">Binding</span><span style="color: red;">&nbsp;Description</span><span style="color: blue;">}</span><span style="color: blue;">"</span><span style="color: blue;">/&gt;</span>
<span style="color: #a31515;">&nbsp;&nbsp;&nbsp;</span><span style="color: blue;">&lt;</span><span style="color: #a31515;">TextBlock</span><span style="color: red;">&nbsp;TextWrapping</span><span style="color: blue;">=</span><span style="color: blue;">"Wrap"</span><span style="color: red;">&nbsp;Text</span><span style="color: blue;">="{</span><span style="color: #a31515;">Binding</span><span style="color: red;">&nbsp;Duration</span><span style="color: blue;">}</span><span style="color: blue;">"</span><span style="color: red;">&nbsp;VerticalAlignment</span><span style="color: blue;">=</span><span style="color: blue;">"Top"</span><span style="color: red;">&nbsp;HorizontalAlignment</span><span style="color: blue;">=</span><span style="color: blue;">"Left"</span><span style="color: blue;">/&gt;</span>
<span style="color: blue;">&lt;/</span><span style="color: #a31515;">StackPanel</span><span style="color: blue;">&gt;</span></pre>
<p>Now, we need to bind our ListBox's IsSelected to the visibility of the drop down panel. &nbsp;Let's add a SelectionChanged event handler for our ListBox. &nbsp;This gives us all the elements that were removed from and added to our selection. &nbsp;First, we need to get the generated ItemContainer from each MovieItem. &nbsp;Second, we need to walk our visual tree to find a drop down panel child. &nbsp;Finally, we can simply toggle the visibility based on the item's selected status.</p>
<p>CODE (add to MainPage class):</p>
<pre style="background: white; color: black; font-family: Consolas;"><span style="color: blue;">void</span>&nbsp;MovieListBox_SelectionChanged(&nbsp;<span style="color: blue;">object</span>&nbsp;sender,&nbsp;<span style="color: #2b91af;">SelectionChangedEventArgs</span>&nbsp;e&nbsp;)
{
&nbsp;&nbsp;&nbsp;<span style="color: #2b91af;">MovieItem</span>&nbsp;movieItem&nbsp;=&nbsp;e.AddedItems[&nbsp;<span style="color: maroon;">0</span>&nbsp;]&nbsp;<span style="color: blue;">as</span>&nbsp;<span style="color: #2b91af;">MovieItem</span>;
&nbsp;&nbsp;&nbsp;<span style="color: #2b91af;">ListBoxItem</span>&nbsp;item&nbsp;=&nbsp;MovieListBox.ItemContainerGenerator.ContainerFromItem(&nbsp;movieItem&nbsp;)&nbsp;<span style="color: blue;">as</span>&nbsp;<span style="color: #2b91af;">ListBoxItem</span>;
&nbsp;&nbsp;&nbsp;<span style="color: #2b91af;">StackPanel</span>&nbsp;dropDownPanel&nbsp;=&nbsp;FindDropDownPanel(&nbsp;item&nbsp;);
&nbsp;&nbsp;&nbsp;<span style="color: blue;">if</span>(&nbsp;dropDownPanel&nbsp;!=&nbsp;<span style="color: blue;">null</span>&nbsp;)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dropDownPanel.Visibility&nbsp;=&nbsp;System.Windows.<span style="color: #2b91af;">Visibility</span>.Visible;
}
 
<span style="color: #2b91af;">StackPanel</span>&nbsp;FindDropDownPanel(&nbsp;<span style="color: #2b91af;">DependencyObject</span>&nbsp;obj&nbsp;)
{
&nbsp;&nbsp;&nbsp;<span style="color: blue;">const</span>&nbsp;<span style="color: blue;">string</span>&nbsp;dropDownName&nbsp;=&nbsp;<span style="color: #a31515;">"DropDownPanel"</span>;
&nbsp;&nbsp;&nbsp;<span style="color: blue;">for</span>(&nbsp;<span style="color: blue;">int</span>&nbsp;i&nbsp;=&nbsp;<span style="color: maroon;">0</span>;&nbsp;i&nbsp;&lt;&nbsp;<span style="color: #2b91af;">VisualTreeHelper</span>.GetChildrenCount(&nbsp;obj&nbsp;);&nbsp;i++&nbsp;)
&nbsp;&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #2b91af;">DependencyObject</span>&nbsp;childObj&nbsp;=&nbsp;<span style="color: #2b91af;">VisualTreeHelper</span>.GetChild(&nbsp;obj,&nbsp;i&nbsp;);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue;">if</span>(&nbsp;childObj&nbsp;!=&nbsp;<span style="color: blue;">null</span>&nbsp;&amp;&amp;&nbsp;childObj&nbsp;<span style="color: blue;">is</span>&nbsp;<span style="color: #2b91af;">StackPanel</span>&nbsp;&amp;&amp;&nbsp;childObj.GetValue(&nbsp;NameProperty&nbsp;).Equals(&nbsp;dropDownName&nbsp;)&nbsp;)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue;">return</span>&nbsp;childObj&nbsp;<span style="color: blue;">as</span>&nbsp;<span style="color: #2b91af;">StackPanel</span>;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue;">else</span>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #2b91af;">StackPanel</span>&nbsp;stackPanel&nbsp;=&nbsp;FindDropDownPanel(&nbsp;childObj&nbsp;);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue;">if</span>(&nbsp;stackPanel&nbsp;!=&nbsp;<span style="color: blue;">null</span>&nbsp;)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue;">return</span>&nbsp;stackPanel;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;<span style="color: blue;">return</span>&nbsp;<span style="color: blue;">null</span>;
}</pre>
<p>Notice we made it specific to a StackPanel and we only did the first added item. This can easily be changed but was done for simplicity's sake. I'm sure this can be done in other ways but hopefully someone finds this simple method useful.</p>]]></content:encoded>
    </item>
    <item>
      <title>Generated destructor debugging in Visual Studio</title>
      <link>https://docs.microsoft.com/archive/blogs/idle_coding/generated-destructor-debugging-in-visual-studio</link>
      <pubDate>Mon, 09 Jul 2012 08:59:00 GMT</pubDate>
      <dc:creator><![CDATA[Ryan Knuth]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/idle_coding/2012/07/09/generated-destructor-debugging-in-visual-studio/</guid>
      <description><![CDATA[I need to add a disclaimer.&nbsp; I understand that this method of adding breakpoints is common for...]]></description>
      <content:encoded><![CDATA[<p>I need to add a disclaimer.&nbsp; I understand that this method of adding breakpoints is common for debuggers like WinDbg.&nbsp; The target audience here is for those that mainly use and feel comfortable with Visual Studio debugging.</p>
<p>Often times, when I&nbsp;start investigating a bug, I know that a good place to start is when a particular class is being destructed.&nbsp; Easy enough, place the breakpoint on your destructor.&nbsp; However, what happens if you haven't created a destructor?&nbsp; Easy enough, code one and rebuild.&nbsp; One final problem, what happens if this given class lives in another component?&nbsp; Let's look at a substantially worthless example that illustrates this point.</p>
<pre style="background: white; color: black; font-family: Consolas;"><span style="color: blue;">namespace</span>&nbsp;ExtNS
{
&nbsp;&nbsp;&nbsp;<span style="color: blue;">class</span>&nbsp;ClassWithDestructor
&nbsp;&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;<span style="color: blue;">public</span>:
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;~ClassWithDestructor()&nbsp;{}
&nbsp;&nbsp;&nbsp;};
 
&nbsp;&nbsp;&nbsp;<span style="color: blue;">class</span>&nbsp;ComponentClass&nbsp;:&nbsp;ClassWithDestructor
&nbsp;&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;<span style="color: blue;">public</span>:
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ComponentClass(&nbsp;<span style="color: blue;">int</span>&nbsp;data&nbsp;)&nbsp;:&nbsp;m_importantData(&nbsp;data&nbsp;)&nbsp;{}
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue;">int</span>&nbsp;GetImportantData()&nbsp;{&nbsp;<span style="color: blue;">return</span>&nbsp;m_importantData;&nbsp;}
&nbsp;&nbsp;&nbsp;<span style="color: blue;">private</span>:
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue;">int</span>&nbsp;m_importantData;
&nbsp;&nbsp;&nbsp;};
}</pre>
<pre style="background: white; color: black; font-family: Consolas;"><span style="color: blue;">void</span>&nbsp;main()
{
&nbsp;&nbsp;&nbsp;ExtNS::ComponentClass*&nbsp;c&nbsp;=&nbsp;<span style="color: blue;">new</span>&nbsp;ExtNS::ComponentClass(&nbsp;<span style="color: maroon;">10</span>&nbsp;);
&nbsp;&nbsp;&nbsp;<span style="color: blue;">delete</span>&nbsp;c;
}</pre>
<p>Imagine for a moment that this class resides in an external component and contains some important, vital data for our program.&nbsp; Furthermore, consider that we have a bug where we have an invalid ComponentClass* and we want to know where our pointer is being deleted.&nbsp; First, we do not have the source code for this external component.&nbsp; Second and more important, the component class does not have an explicit destructor but its parent may.</p>
<p>Enter a nice feature in Visual Studio.&nbsp; We know that if a destructor is not explicitly defined but a parent class does, the compiler will generate one for us.&nbsp; We proceed with this knowledge.&nbsp; Ensure that symbols are loaded for the given component's library or executable (an explanation of how to accomplish this is outside the scope of this post).&nbsp; In the breakpoint window, click on the <strong>new</strong> dropdown and select "<strong>Break at Function...</strong>"&nbsp; Mine maps to [<strong>Ctrl+d, n</strong>].&nbsp; Now, we enter our generated destructor as the function: <strong>ExtNS::ComponentClass::~ComponentClass</strong>.</p>
<p>If the function is found, you will see it as valid in the breakpoints window.&nbsp; Attach the debugger to a running instance and run the scenario.&nbsp; The breakpoint will hit whenever our class is being destructed.&nbsp; Obviously, we will not have the source code to see the breakpoint, but we can use the callstack to trace where we have stopped.</p>]]></content:encoded>
    </item>
  </channel>
</rss>