<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:blogChannel="http://backend.userland.com/blogChannelModule" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:pingback="http://madskills.com/public/xml/rss/module/pingback/" 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:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">
  <channel>
    <title>Infinite Codex</title>
    <description>Unlimited Possibilities through Code</description>
    <link>http://infinitecodex.com/infinitecodex/</link>
    <docs>http://www.rssboard.org/rss-specification</docs>
    <generator>BlogEngine.NET 2.5.0.5</generator>
    <language>en-GB</language>
    <blogChannel:blogRoll>http://infinitecodex.com/infinitecodex/opml.axd</blogChannel:blogRoll>
    <blogChannel:blink>http://www.dotnetblogengine.net/syndication.axd</blogChannel:blink>
    <dc:creator>Jason Short</dc:creator>
    <dc:title>Infinite Codex</dc:title>
    <geo:lat>47.370000</geo:lat>
    <geo:long>122.200000</geo:long>
    <atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/Vistadb" /><feedburner:info uri="vistadb" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><feedburner:feedFlare href="http://www.bloglines.com/sub/http://feeds.feedburner.com/Vistadb" src="http://www.bloglines.com/images/sub_modern11.gif">Subscribe with Bloglines</feedburner:feedFlare><feedburner:feedFlare href="http://fusion.google.com/add?feedurl=http%3A%2F%2Ffeeds.feedburner.com%2FVistadb" src="http://buttons.googlesyndication.com/fusion/add.gif">Subscribe with Google</feedburner:feedFlare><feedburner:feedFlare href="http://www.pageflakes.com/subscribe.aspx?url=http%3A%2F%2Ffeeds.feedburner.com%2FVistadb" src="http://www.pageflakes.com/ImageFile.ashx?instanceId=Static_4&amp;fileName=ATP_blu_91x17.gif">Subscribe with Pageflakes</feedburner:feedFlare><feedburner:browserFriendly>Visit the VistaDB.Net forums for more discussions about database and dot net technology.</feedburner:browserFriendly><item>
      <title>Using a custom attribute to determine type at runtime</title>
      <description>&lt;p&gt;On a Windows Phone 7 project I am currently building I had a need to build a factory that instantiates different concrete classes depending upon an object at runtime.&amp;#160;&amp;#160; I have a number of information feeds, that all have different classes built to actually go get their data.&amp;#160; One for RSS Feeds, one for Twitter, etc.&amp;#160; Each Feed has a property for the FeedType, this is the information needed to determine what class to instantiate at runtime. &lt;/p&gt;  &lt;p&gt;I have written this pattern many times, but I ran across an interesting post on &lt;a href="http://stackoverflow.com/questions/4387573/can-i-use-attributes-so-my-factory-knows-what-it-can-should-instantiate-without/4387761" target="_blank"&gt;StackOverflow&lt;/a&gt; where Steven gave a different approach to solving this without the classic giant switch statement in the Create method.&amp;#160;&amp;#160; I thought it was neat enough to use in my application and share here.&lt;/p&gt;  &lt;p&gt;There are a couple of steps you have to take, but none of them are difficult.&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Decorate your objects with a custom attribute &lt;/li&gt;    &lt;li&gt;Build the object types using reflection &lt;/li&gt;    &lt;li&gt;Implement your factory method &lt;/li&gt; &lt;/ul&gt;  &lt;h2&gt;Custom Attribute&lt;/h2&gt;  &lt;p&gt;The attribute I added is called FeedTypeAttribute, I then add it to the concrete feed processor classes.&lt;/p&gt;  &lt;div id="codeSnippetWrapper"&gt;   &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: #0000ff"&gt;class&lt;/span&gt; FeedTypeAttribute : Attribute&lt;br /&gt;{&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;private&lt;/span&gt; &lt;span style="color: #0000ff"&gt;int&lt;/span&gt; _feedType;&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; FeedTypeAttribute(&lt;span style="color: #0000ff"&gt;int&lt;/span&gt; feedType)&lt;br /&gt;    {&lt;br /&gt;        _feedType = feedType;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;int&lt;/span&gt; FeedTypeId&lt;br /&gt;    {&lt;br /&gt;        get&lt;br /&gt;        {&lt;br /&gt;            &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; _feedType;&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;

  &lt;br /&gt;Adding the attribute to a class looks like the following.&lt;/div&gt;

&lt;div&gt;&amp;#160;&lt;/div&gt;

&lt;div id="codeSnippetWrapper"&gt;
  &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;[FeedTypeAttribute(1)]&lt;br /&gt;&lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;class&lt;/span&gt; StaticFeedProcessor : IFeedProcessor&lt;br /&gt;{&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; StaticFeedProcessor()&lt;br /&gt;    {&lt;br /&gt;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; ProcessFeedModel(FeedModel feedModel)&lt;br /&gt;    {&lt;br /&gt;        &lt;span style="color: #0000ff"&gt;throw&lt;/span&gt; &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; NotImplementedException();&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;

  &lt;br /&gt;Note that this class would be a FeedType of 1 in my data, but how do you determine what class that is during runtime?&amp;#160; The answer is reflection (and yes, this does work on Windows Phone 7).&lt;/div&gt;

&lt;div&gt;&amp;#160;&lt;/div&gt;

&lt;h2&gt;Factory Method Using Custom Attributes&lt;/h2&gt;

&lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 105.47%; padding-right: 4px; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; direction: ltr; height: 407px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;p&gt;&lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;class&lt;/span&gt; FeedProcessorFactory : IFeedProcessorFactory&lt;br /&gt;{&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;private&lt;/span&gt; &lt;span style="color: #0000ff"&gt;static&lt;/span&gt; Dictionary&amp;lt;&lt;span style="color: #0000ff"&gt;int&lt;/span&gt;, Type&amp;gt; processorList = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; Dictionary&amp;lt;&lt;span style="color: #0000ff"&gt;int&lt;/span&gt;, Type&amp;gt;();&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;static&lt;/span&gt; FeedProcessorFactory()&lt;br /&gt;    {&lt;br /&gt;        &lt;span style="color: #008000"&gt;// Get the types in this assembly that implement our custom attribute&lt;/span&gt;&lt;br /&gt;        var targetTypes = from type &lt;span style="color: #0000ff"&gt;in&lt;/span&gt; Assembly.GetExecutingAssembly().GetTypes() &lt;br /&gt;                         &lt;span style="color: #0000ff"&gt;where&lt;/span&gt; type.CanBeTreatedAsType(&lt;span style="color: #0000ff"&gt;typeof&lt;/span&gt;(IFeedProcessor))&lt;br /&gt;                         &lt;span style="color: #0000ff"&gt;where&lt;/span&gt; !type.IsAbstract &amp;amp;&amp;amp; !type.IsInterface&lt;br /&gt;                         let customAttributes = type.GetCustomAttributes( &lt;span style="color: #0000ff"&gt;typeof&lt;/span&gt;(FeedTypeAttribute), &lt;span style="color: #0000ff"&gt;false&lt;/span&gt;)&lt;br /&gt;                         let attribute = customAttributes[0] &lt;span style="color: #0000ff"&gt;as&lt;/span&gt; FeedTypeAttribute&lt;br /&gt;                         select &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; { type, attribute.FeedTypeId };&lt;br /&gt;&lt;br /&gt;        processorList = targetTypes.ToDictionary(p =&amp;gt; p.FeedTypeId, p =&amp;gt; p.type);&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; IFeedProcessor CreateProcessorByFeedType(&lt;span style="color: #0000ff"&gt;int&lt;/span&gt; feedId)&lt;br /&gt;    {&lt;br /&gt;        Type feedType = processorList[feedId];&lt;br /&gt;&lt;br /&gt;        &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; Activator.CreateInstance(feedType) &lt;span style="color: #0000ff"&gt;as&lt;/span&gt; IFeedProcessor;&lt;br /&gt;    }&lt;br /&gt;}&lt;/p&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;The key here is the type.GetCustomAttributes() call.&amp;#160; The linq expression gets all the type of the current assembly where the type can be assigned from the IFeedProcessor class.&amp;#160; We have to ensure the class is not abstract or an interface, and then get the custom attributes.&amp;#160; &lt;/p&gt;

&lt;p&gt;The let clause in the linq expression can be thought of like a local temporary variable.&amp;#160; Assigning the attributes to it, and then processing them in the final select.&lt;/p&gt;

&lt;h2&gt;Consuming the Factory&lt;/h2&gt;

&lt;p&gt;Consuming the factory is then as simple as instantiating a factory object and calling the CreateProcessorByFeedType function.&amp;#160; A fully allocated processor is returned ready to handle the feed.&lt;/p&gt;

&lt;div id="codeSnippetWrapper"&gt;
  &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: #008000"&gt;// This is in my container object&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #0000ff"&gt;private&lt;/span&gt; &lt;span style="color: #0000ff"&gt;static&lt;/span&gt; IFeedProcessorFactory _feedProcessorFactory = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; FeedProcessorFactory();&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: #008000"&gt;// This is in the function to process the feeds&lt;/span&gt;&lt;br /&gt;IFeedProcessor processor = _feedProcessorFactory.CreateProcessorByFeedType(feed.FeedType);&lt;br /&gt;processor.ProcessFeedModel(feed);&lt;br /&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;h2&gt;Less Coupling is Good&lt;/h2&gt;

&lt;div&gt;This code allows for the addition of new processor classes just by building the class and adding the custom attribute.&amp;#160; Of course you should check if the feedtype is not supported before trying to use the object (I omitted some code used for safety checking).&lt;/div&gt;

&lt;div&gt;&amp;#160;&lt;/div&gt;

&lt;div&gt;If a newer class is created in the future to replace a current one I only have to change the custom attribute to handle it.&amp;#160; No switch statements, or remembering to update a config somewhere.&lt;/div&gt;

&lt;div&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/Vistadb?a=whlF4oXLRWk:NuR8uk1JmDw:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Vistadb?i=whlF4oXLRWk:NuR8uk1JmDw:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Vistadb?a=whlF4oXLRWk:NuR8uk1JmDw:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Vistadb?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Vistadb?a=whlF4oXLRWk:NuR8uk1JmDw:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Vistadb?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/Vistadb/~4/whlF4oXLRWk" height="1" width="1"/&gt;</description>
      <link>http://feedproxy.google.com/~r/Vistadb/~3/whlF4oXLRWk/post.aspx</link>
      <author>jasonshort@infinitecodex.com</author>
      <comments>http://infinitecodex.com/infinitecodex/post/2012/02/06/Using-a-custom-attribute-to-determine-type-at-runtime.aspx#comment</comments>
      <guid isPermaLink="false">http://infinitecodex.com/infinitecodex/post.aspx?id=8b6e9cf1-e303-4557-bf08-2803ba58e1ba</guid>
      <pubDate>Mon, 06 Feb 2012 01:46:00 -1500</pubDate>
      <category>WP7</category>
      <dc:publisher>jshort</dc:publisher>
      <pingback:server>http://infinitecodex.com/infinitecodex/pingback.axd</pingback:server>
      <pingback:target>http://infinitecodex.com/infinitecodex/post.aspx?id=8b6e9cf1-e303-4557-bf08-2803ba58e1ba</pingback:target>
      <slash:comments>0</slash:comments>
      <trackback:ping>http://infinitecodex.com/infinitecodex/trackback.axd?id=8b6e9cf1-e303-4557-bf08-2803ba58e1ba</trackback:ping>
      <wfw:comment>http://infinitecodex.com/infinitecodex/post/2012/02/06/Using-a-custom-attribute-to-determine-type-at-runtime.aspx#comment</wfw:comment>
      <wfw:commentRss>http://infinitecodex.com/infinitecodex/syndication.axd?post=8b6e9cf1-e303-4557-bf08-2803ba58e1ba</wfw:commentRss>
    <feedburner:origLink>http://infinitecodex.com/infinitecodex/post.aspx?id=8b6e9cf1-e303-4557-bf08-2803ba58e1ba</feedburner:origLink></item>
    <item>
      <title>Is this .Net Type Assignable from another Type?</title>
      <description>&lt;p&gt;I have run into this a few times and always have to go to the MSDN to find the answer.&amp;#160; I have a situation where I needed to determine if a given type can be treated as a base type in an object factory.&amp;#160; I wanted to be able to create my concrete classes without having to do a switch statement for each type.&lt;/p&gt;  &lt;p&gt;First I had to determine if the types were assignable to each other, then find the type to implement.&amp;#160; I will cover that in another article.&amp;#160; In this one I just want to cover the assignment test.&lt;/p&gt;  &lt;h2&gt;Can this type be assigned?&lt;/h2&gt;  &lt;p&gt;There is a function &lt;a href="http://msdn.microsoft.com/en-us/library/system.type.isassignablefrom.aspx" target="_blank"&gt;IsAssignableFrom&lt;/a&gt; that you can call on a System.Type.&amp;#160; &lt;/p&gt;  &lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;   &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: #0000ff"&gt;if&lt;/span&gt;( ParentType &lt;span style="color: #0000ff"&gt;is&lt;/span&gt; ChildType )&lt;/pre&gt;

  &lt;br /&gt;&lt;/div&gt;

&lt;p&gt;It actually has to be written the other way around.&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: #0000ff"&gt;if&lt;/span&gt;( ChildType.IsAssignableFrom(ParentType) )&lt;/pre&gt;

  &lt;br /&gt;&lt;/div&gt;

&lt;h2&gt;Quick Extension Method&lt;/h2&gt;

&lt;p&gt;So instead of having to do that all over my code, I wrote an extension method to allow me to do it following a different ordering.&amp;#160; I actually got this basic idea from one of the comments on the MSDN page.&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: #0000ff"&gt;if&lt;/span&gt;( parentType.CanBeTreatedAsType(childType) )&lt;/pre&gt;

  &lt;br /&gt;&lt;/div&gt;

&lt;p&gt;As you can see the extension method lets you write the syntax in a more natural manner.&amp;#160; Your preference may differ, but this makes more sense to me.&lt;/p&gt;

&lt;h2&gt;Example Code&lt;/h2&gt;

&lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;static&lt;/span&gt; &lt;span style="color: #0000ff"&gt;class&lt;/span&gt; DataExtensionMethods&lt;br /&gt;{&lt;br /&gt;        &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;static&lt;/span&gt; &lt;span style="color: #0000ff"&gt;bool&lt;/span&gt; CanBeTreatedAsType(&lt;span style="color: #0000ff"&gt;this&lt;/span&gt; Type CurrentType, Type TypeToCompareWith)&lt;br /&gt;        {&lt;br /&gt;            &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (CurrentType == &lt;span style="color: #0000ff"&gt;null&lt;/span&gt; || TypeToCompareWith == &lt;span style="color: #0000ff"&gt;null&lt;/span&gt;)&lt;br /&gt;                &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; &lt;span style="color: #0000ff"&gt;false&lt;/span&gt;;&lt;br /&gt;&lt;br /&gt;            &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; TypeToCompareWith.IsAssignableFrom(CurrentType);&lt;br /&gt;        }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span style="color: #0000ff"&gt;void&lt;/span&gt; Main()&lt;br /&gt;{&lt;br /&gt;    System.Type parentType = &lt;span style="color: #0000ff"&gt;typeof&lt;/span&gt;(ParentClass);&lt;br /&gt;    System.Type childType = &lt;span style="color: #0000ff"&gt;typeof&lt;/span&gt;(ChildClass);&lt;br /&gt;    &lt;br /&gt;    &lt;span style="color: #0000ff"&gt;bool&lt;/span&gt; ChildToParent = childType.CanBeTreatedAsType(parentType);&lt;br /&gt;    Console.WriteLine(&lt;span style="color: #006080"&gt;&amp;quot;Child can be treated as parent: &amp;quot;&lt;/span&gt; + ChildToParent );&lt;br /&gt;     &lt;br /&gt;    &lt;span style="color: #0000ff"&gt;bool&lt;/span&gt; ParentAsChild = parentType.CanBeTreatedAsType(childType);&lt;br /&gt;    Console.WriteLine(&lt;span style="color: #006080"&gt;&amp;quot;Parent can be treated as child: &amp;quot;&lt;/span&gt; + ParentAsChild );&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;class&lt;/span&gt; ParentClass&lt;br /&gt;{&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; ParentClass()&lt;br /&gt;    {&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;class&lt;/span&gt; ChildClass : ParentClass&lt;br /&gt;{&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; ChildClass() : &lt;span style="color: #0000ff"&gt;base&lt;/span&gt;()&lt;br /&gt;    {&lt;br /&gt;    &lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;

  &lt;br /&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/Vistadb?a=dK7PIIIT3i8:1JiWQBfPhZo:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Vistadb?i=dK7PIIIT3i8:1JiWQBfPhZo:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Vistadb?a=dK7PIIIT3i8:1JiWQBfPhZo:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Vistadb?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Vistadb?a=dK7PIIIT3i8:1JiWQBfPhZo:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Vistadb?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/Vistadb/~4/dK7PIIIT3i8" height="1" width="1"/&gt;</description>
      <link>http://feedproxy.google.com/~r/Vistadb/~3/dK7PIIIT3i8/post.aspx</link>
      <author>jasonshort@infinitecodex.com</author>
      <comments>http://infinitecodex.com/infinitecodex/post/2012/02/02/Is-this-Net-Type-Assignable-from-another-Type.aspx#comment</comments>
      <guid isPermaLink="false">http://infinitecodex.com/infinitecodex/post.aspx?id=9bcc7915-1dcb-4f9a-a2be-48810d7486d4</guid>
      <pubDate>Thu, 02 Feb 2012 09:20:17 -1500</pubDate>
      <category>WP7</category>
      <dc:publisher>jshort</dc:publisher>
      <pingback:server>http://infinitecodex.com/infinitecodex/pingback.axd</pingback:server>
      <pingback:target>http://infinitecodex.com/infinitecodex/post.aspx?id=9bcc7915-1dcb-4f9a-a2be-48810d7486d4</pingback:target>
      <slash:comments>0</slash:comments>
      <trackback:ping>http://infinitecodex.com/infinitecodex/trackback.axd?id=9bcc7915-1dcb-4f9a-a2be-48810d7486d4</trackback:ping>
      <wfw:comment>http://infinitecodex.com/infinitecodex/post/2012/02/02/Is-this-Net-Type-Assignable-from-another-Type.aspx#comment</wfw:comment>
      <wfw:commentRss>http://infinitecodex.com/infinitecodex/syndication.axd?post=9bcc7915-1dcb-4f9a-a2be-48810d7486d4</wfw:commentRss>
    <feedburner:origLink>http://infinitecodex.com/infinitecodex/post.aspx?id=9bcc7915-1dcb-4f9a-a2be-48810d7486d4</feedburner:origLink></item>
    <item>
      <title>Debug Secondary Tiles</title>
      <description>&lt;p&gt;This is another of those posts for my future self, because I know I won’t remember this little tip.&lt;/p&gt;  &lt;h2&gt;Set startup through app manifest&lt;/h2&gt;  &lt;p&gt;The WMAppManifest.xml has a property that tells it where to send the default launch of the application.&lt;/p&gt;  &lt;pre class="csharpcode"&gt;    &amp;lt;Tasks&amp;gt;
      &amp;lt;DefaultTask Name=&lt;span class="str"&gt;&amp;quot;_default&amp;quot;&lt;/span&gt; NavigationPage=&lt;span class="str"&gt;&amp;quot;MainPage.xaml&amp;quot;&lt;/span&gt; /&amp;gt;
    &amp;lt;/Tasks&amp;gt;&lt;/pre&gt;

&lt;p&gt;So the normal launch page is MainPage.xaml. But you can change it to another page, and include your parameters just like from a secondary tile!&lt;/p&gt;

&lt;pre class="csharpcode"&gt;    &amp;lt;Tasks&amp;gt;
      &amp;lt;DefaultTask Name=&lt;span class="str"&gt;&amp;quot;_default&amp;quot;&lt;/span&gt; NavigationPage=&lt;span class="str"&gt;&amp;quot;/TileDetails.xaml?myid=2&amp;quot;&lt;/span&gt; /&amp;gt;
    &amp;lt;/Tasks&amp;gt;&lt;/pre&gt;

&lt;p&gt;Now you can just press F5 and debug just as if that secondary tile had been clicked.&lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/Vistadb?a=VR8O4gsBoBM:keOh__3e87g:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Vistadb?i=VR8O4gsBoBM:keOh__3e87g:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Vistadb?a=VR8O4gsBoBM:keOh__3e87g:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Vistadb?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Vistadb?a=VR8O4gsBoBM:keOh__3e87g:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Vistadb?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/Vistadb/~4/VR8O4gsBoBM" height="1" width="1"/&gt;</description>
      <link>http://feedproxy.google.com/~r/Vistadb/~3/VR8O4gsBoBM/post.aspx</link>
      <author>jasonshort@infinitecodex.com</author>
      <comments>http://infinitecodex.com/infinitecodex/post/2012/01/04/Debug-Secondary-Tiles.aspx#comment</comments>
      <guid isPermaLink="false">http://infinitecodex.com/infinitecodex/post.aspx?id=3067465a-4bc7-4400-b99e-bc533b89faa6</guid>
      <pubDate>Wed, 04 Jan 2012 02:39:00 -1500</pubDate>
      <category>WP7</category>
      <dc:publisher>jshort</dc:publisher>
      <pingback:server>http://infinitecodex.com/infinitecodex/pingback.axd</pingback:server>
      <pingback:target>http://infinitecodex.com/infinitecodex/post.aspx?id=3067465a-4bc7-4400-b99e-bc533b89faa6</pingback:target>
      <slash:comments>0</slash:comments>
      <trackback:ping>http://infinitecodex.com/infinitecodex/trackback.axd?id=3067465a-4bc7-4400-b99e-bc533b89faa6</trackback:ping>
      <wfw:comment>http://infinitecodex.com/infinitecodex/post/2012/01/04/Debug-Secondary-Tiles.aspx#comment</wfw:comment>
      <wfw:commentRss>http://infinitecodex.com/infinitecodex/syndication.axd?post=3067465a-4bc7-4400-b99e-bc533b89faa6</wfw:commentRss>
    <feedburner:origLink>http://infinitecodex.com/infinitecodex/post.aspx?id=3067465a-4bc7-4400-b99e-bc533b89faa6</feedburner:origLink></item>
    <item>
      <title>Coding 4 Fun Phone Toolkit updated</title>
      <description>&lt;p&gt;If you have not looked at the toolkit before you seriously owe it to yourself, go get it now!&lt;/p&gt;  &lt;p&gt;&lt;a href="http://coding4fun.codeplex.com/"&gt;Coding 4 Fun Phone Toolkit&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Windows Phone Geek has also done a great intro post on one of the new controls (the MetroFlow control).&amp;#160; &lt;a href="http://www.windowsphonegeek.com/articles/Getting-Started-with-the-Coding4Fun-toolkit-MetroFlow-Control"&gt;Getting started with MetroFlow Control is a great read&lt;/a&gt;, even just to get up to speed with the overall concepts of the toolkit.&lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/Vistadb?a=UFZGs4DBmJw:mQGSngWKjK4:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Vistadb?i=UFZGs4DBmJw:mQGSngWKjK4:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Vistadb?a=UFZGs4DBmJw:mQGSngWKjK4:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Vistadb?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Vistadb?a=UFZGs4DBmJw:mQGSngWKjK4:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Vistadb?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/Vistadb/~4/UFZGs4DBmJw" height="1" width="1"/&gt;</description>
      <link>http://feedproxy.google.com/~r/Vistadb/~3/UFZGs4DBmJw/post.aspx</link>
      <author>jasonshort@infinitecodex.com</author>
      <comments>http://infinitecodex.com/infinitecodex/post/2012/01/03/Coding-4-Fun-Phone-Toolkit-updated.aspx#comment</comments>
      <guid isPermaLink="false">http://infinitecodex.com/infinitecodex/post.aspx?id=4cd239b5-14ad-42a3-963b-d1193de97f21</guid>
      <pubDate>Tue, 03 Jan 2012 02:37:31 -1500</pubDate>
      <category>WP7</category>
      <dc:publisher>jshort</dc:publisher>
      <pingback:server>http://infinitecodex.com/infinitecodex/pingback.axd</pingback:server>
      <pingback:target>http://infinitecodex.com/infinitecodex/post.aspx?id=4cd239b5-14ad-42a3-963b-d1193de97f21</pingback:target>
      <slash:comments>2</slash:comments>
      <trackback:ping>http://infinitecodex.com/infinitecodex/trackback.axd?id=4cd239b5-14ad-42a3-963b-d1193de97f21</trackback:ping>
      <wfw:comment>http://infinitecodex.com/infinitecodex/post/2012/01/03/Coding-4-Fun-Phone-Toolkit-updated.aspx#comment</wfw:comment>
      <wfw:commentRss>http://infinitecodex.com/infinitecodex/syndication.axd?post=4cd239b5-14ad-42a3-963b-d1193de97f21</wfw:commentRss>
    <feedburner:origLink>http://infinitecodex.com/infinitecodex/post.aspx?id=4cd239b5-14ad-42a3-963b-d1193de97f21</feedburner:origLink></item>
    <item>
      <title>Click back twice to exit app?</title>
      <description>&lt;p&gt;I have been adding animations to a Windows Phone 7 app that has a panorama control and ran into a problem I have seen others post online.&amp;#160; I figured it out, so I thought I would take a minute to explain how.&lt;/p&gt;  &lt;h2&gt;Get ready to add transitions&lt;/h2&gt;  &lt;p&gt;The &lt;a href="http://silverlight.codeplex.com/"&gt;Silverlight Toolkit&lt;/a&gt; is the way you want to go about adding quick and easy animations when a page loads and navigates away from the current page.&lt;/p&gt;  &lt;p&gt;If you are not familiar with the basics visit the link above, or read this really good tutorial about &lt;a href="http://www.windowsphonegeek.com/articles/wp7-transitions-in-depth--custom-transitions"&gt;wp7 page transitions&lt;/a&gt; on Windows Phone Geek.&lt;/p&gt;  &lt;p&gt;The basics are that you have to include the toolkit, and you have to modify the root frame of your application to be a transition page instead of a normal phone page.&lt;/p&gt;  &lt;p&gt;In a typical application you have the RootFrame declared in your App.xaml.cs like this:&lt;/p&gt;  &lt;pre class="csharpcode"&gt;    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;partial&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; App : Application
    {
        &lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;
        &lt;span class="rem"&gt;/// Provides easy access to the root frame of the Phone Application.&lt;/span&gt;
        &lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;
        &lt;span class="rem"&gt;/// &amp;lt;returns&amp;gt;The root frame of the Phone Application.&amp;lt;/returns&amp;gt;&lt;/span&gt;
        &lt;span class="kwrd"&gt;public&lt;/span&gt; PhoneApplicationFrame RootFrame { get; &lt;span class="kwrd"&gt;private&lt;/span&gt; set; }
    }&lt;/pre&gt;

&lt;p&gt;But for transitions to happen you need to change the object to a TransitionFrame when your InitializePhoneApplication is called.&lt;/p&gt;

&lt;pre class="csharpcode"&gt;            &lt;span class="rem"&gt;// REPLACE THE FIRST LINE WITH THE SECOND&lt;/span&gt;
            &lt;span class="rem"&gt;// RootFrame = new PhoneApplicationFrame();&lt;/span&gt;
            RootFrame = &lt;span class="kwrd"&gt;new&lt;/span&gt; TransitionFrame();
&lt;style type="text/css"&gt;.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/style&gt;&lt;/pre&gt;

&lt;p&gt;This will give you the ability to add transitions to your page.&lt;/p&gt;

&lt;p&gt;I prefer to define my transition style at the application level, rather than the page level.&amp;#160; Usually I want all the pages to behave the same, so this gives a nice central point for all of them to reference it.&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;In your App.xaml add a style like this:&lt;/p&gt;

&lt;pre class="csharpcode"&gt;        &amp;lt;Application.Resources&amp;gt;
            &amp;lt;Style x:Key=&lt;span class="str"&gt;&amp;quot;TransitionPageStyle&amp;quot;&lt;/span&gt; TargetType=&lt;span class="str"&gt;&amp;quot;phone:PhoneApplicationPage&amp;quot;&lt;/span&gt;&amp;gt;
            &amp;lt;Setter Property=&lt;span class="str"&gt;&amp;quot;toolkit:TransitionService.NavigationInTransition&amp;quot;&lt;/span&gt;&amp;gt;
                &amp;lt;Setter.Value&amp;gt;
                    &amp;lt;toolkit:NavigationInTransition&amp;gt;
                        &amp;lt;toolkit:NavigationInTransition.Backward&amp;gt;
                            &amp;lt;toolkit:TurnstileTransition Mode=&lt;span class="str"&gt;&amp;quot;BackwardIn&amp;quot;&lt;/span&gt;/&amp;gt;
                        &amp;lt;/toolkit:NavigationInTransition.Backward&amp;gt;
                        &amp;lt;toolkit:NavigationInTransition.Forward&amp;gt;
                            &amp;lt;toolkit:TurnstileTransition Mode=&lt;span class="str"&gt;&amp;quot;ForwardIn&amp;quot;&lt;/span&gt;/&amp;gt;
                        &amp;lt;/toolkit:NavigationInTransition.Forward&amp;gt;
                    &amp;lt;/toolkit:NavigationInTransition&amp;gt;
                &amp;lt;/Setter.Value&amp;gt;
            &amp;lt;/Setter&amp;gt;
            &amp;lt;Setter Property=&lt;span class="str"&gt;&amp;quot;toolkit:TransitionService.NavigationOutTransition&amp;quot;&lt;/span&gt;&amp;gt;
                &amp;lt;Setter.Value&amp;gt;
                    &amp;lt;toolkit:NavigationOutTransition&amp;gt;
                        &amp;lt;toolkit:NavigationOutTransition.Backward&amp;gt;
                            &amp;lt;toolkit:TurnstileTransition Mode=&lt;span class="str"&gt;&amp;quot;BackwardOut&amp;quot;&lt;/span&gt;/&amp;gt;
                        &amp;lt;/toolkit:NavigationOutTransition.Backward&amp;gt;
                        &amp;lt;toolkit:NavigationOutTransition.Forward&amp;gt;
                            &amp;lt;toolkit:TurnstileTransition Mode=&lt;span class="str"&gt;&amp;quot;ForwardOut&amp;quot;&lt;/span&gt;/&amp;gt;
                        &amp;lt;/toolkit:NavigationOutTransition.Forward&amp;gt;
                    &amp;lt;/toolkit:NavigationOutTransition&amp;gt;
                &amp;lt;/Setter.Value&amp;gt;
            &amp;lt;/Setter&amp;gt;
        &amp;lt;/Style&amp;gt;
            
        &lt;span class="rem"&gt;// Other resources here...&lt;/span&gt;
    &amp;lt;/Application.Resources&amp;gt;&lt;/pre&gt;
&lt;style type="text/css"&gt;

.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;This is defining a in and out transition that is a turnstile effect.&amp;#160; This is how almost all of the built in applications behave.&lt;/p&gt;

&lt;h2&gt;Modify the page&lt;/h2&gt;

&lt;p&gt;Add the transition to each page you want to use this behavior in the XAML.&lt;/p&gt;

&lt;pre class="csharpcode"&gt;&amp;lt;phone:PhoneApplicationPage 
    x:Class=&lt;span class="str"&gt;&amp;quot;YourApplication.MainPage&amp;quot;&lt;/span&gt;
    xmlns=&lt;span class="str"&gt;&amp;quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&amp;quot;&lt;/span&gt;
   &lt;span class="rem"&gt;// the rest of your xmlns stays the same, you need to add the toolkit and the style &lt;/span&gt;

   &lt;span class="rem"&gt;// This reference loads the toolkit controls for this page&lt;/span&gt;
   xmlns:toolkit=&lt;span class="str"&gt;&amp;quot;clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit&amp;quot;&lt;/span&gt;

    &lt;span class="rem"&gt;// This is named in the App.xaml (you can change it)&lt;/span&gt;
    Style=&lt;span class="str"&gt;&amp;quot;{StaticResource TransitionPageStyle}&amp;quot;&lt;/span&gt;&amp;gt;

    &lt;span class="rem"&gt;// the rest of your page XAML stays the same....&lt;/span&gt;

/&amp;gt;&lt;/pre&gt;
&lt;style type="text/css"&gt;

.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;Do this for each page you want to use the transition effect.&lt;/p&gt;

&lt;h2&gt;Why do I have to hit back twice?&lt;/h2&gt;

&lt;p&gt;Phew, now to the reason I wrote this post…&lt;/p&gt;

&lt;p&gt;In some situations you will notice that hitting back from your main page will navigate out, but the same page will appear rather than exiting the application. This will surely cause you to fail certification, and probably annoy a few users.&lt;/p&gt;

&lt;p&gt;There are a couple different reasons why I have seen this happen.&lt;/p&gt;

&lt;h2&gt;There can be only one… RootFrame&lt;/h2&gt;

&lt;p&gt;The core of all the issues is that you can only have ONE RootFrame on your page.&amp;#160; If you are allocating a second frame for the transition and assigning it to the RootFrame you have two of them around.&amp;#160; &lt;/p&gt;

&lt;pre class="csharpcode"&gt;            RootFrame = &lt;span class="kwrd"&gt;new&lt;/span&gt; PhoneApplicationFrame();

            &lt;span class="rem"&gt;// This will make a SECOND Frame in your app&lt;/span&gt;
            RootFrame = &lt;span class="kwrd"&gt;new&lt;/span&gt; TransitionFrame();
&lt;style type="text/css"&gt;.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/style&gt;&lt;/pre&gt;

&lt;p&gt;This is the mistake I have seen online quite a bit.&amp;#160; People think they have to add a new TransitionFrame allocation and leave the original one in place.&amp;#160; You &lt;strong&gt;must delete the PhoneApplicationFrame() allocation line&lt;/strong&gt;!&lt;/p&gt;

&lt;p&gt;A more subtle version of this same bug is the one I ran into.&amp;#160; The Panorama project template creates a RootFrame for you in the App.xaml like this:&lt;/p&gt;

&lt;pre class="csharpcode"&gt;   &amp;lt;Application.RootVisual&amp;gt;
        &amp;lt;toolkit:PhoneApplicationFrame x:Name=&lt;span class="str"&gt;&amp;quot;RootFrame&amp;quot;&lt;/span&gt; Source=&lt;span class="str"&gt;&amp;quot;/MainPage.xaml&amp;quot;&lt;/span&gt;/&amp;gt;
    &amp;lt;/Application.RootVisual&amp;gt;&lt;/pre&gt;
&lt;style type="text/css"&gt;

.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;This will cause a second allocation of a PhoneApplicationFrame!&lt;/p&gt;

&lt;p&gt;If you remove that code from the xaml you will now safely be able to hit back and leave the application.&lt;/p&gt;


&lt;style type="text/css"&gt;

.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/Vistadb?a=3J7zrur1fL4:6IpgxBl4Vr8:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Vistadb?i=3J7zrur1fL4:6IpgxBl4Vr8:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Vistadb?a=3J7zrur1fL4:6IpgxBl4Vr8:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Vistadb?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Vistadb?a=3J7zrur1fL4:6IpgxBl4Vr8:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Vistadb?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/Vistadb/~4/3J7zrur1fL4" height="1" width="1"/&gt;</description>
      <link>http://feedproxy.google.com/~r/Vistadb/~3/3J7zrur1fL4/post.aspx</link>
      <author>jasonshort@infinitecodex.com</author>
      <comments>http://infinitecodex.com/infinitecodex/post/2011/12/09/Click-back-twice-to-exit-app.aspx#comment</comments>
      <guid isPermaLink="false">http://infinitecodex.com/infinitecodex/post.aspx?id=e9dae518-7739-4e2d-b583-16956a321627</guid>
      <pubDate>Fri, 09 Dec 2011 08:11:49 -1500</pubDate>
      <category>WP7</category>
      <dc:publisher>jshort</dc:publisher>
      <pingback:server>http://infinitecodex.com/infinitecodex/pingback.axd</pingback:server>
      <pingback:target>http://infinitecodex.com/infinitecodex/post.aspx?id=e9dae518-7739-4e2d-b583-16956a321627</pingback:target>
      <slash:comments>0</slash:comments>
      <trackback:ping>http://infinitecodex.com/infinitecodex/trackback.axd?id=e9dae518-7739-4e2d-b583-16956a321627</trackback:ping>
      <wfw:comment>http://infinitecodex.com/infinitecodex/post/2011/12/09/Click-back-twice-to-exit-app.aspx#comment</wfw:comment>
      <wfw:commentRss>http://infinitecodex.com/infinitecodex/syndication.axd?post=e9dae518-7739-4e2d-b583-16956a321627</wfw:commentRss>
    <feedburner:origLink>http://infinitecodex.com/infinitecodex/post.aspx?id=e9dae518-7739-4e2d-b583-16956a321627</feedburner:origLink></item>
    <item>
      <title>Explorer Search options for file and IE favorites</title>
      <description>&lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Do you every need to search in Explorer (your Windows Explorer, not the Internet one) for files of a specific size range?&amp;#160; A coworker showed this to me and I wanted to write it down so I don’t forget it!&lt;/p&gt;  &lt;h2&gt;Search by Size: range&lt;/h2&gt;  &lt;p&gt;&lt;a href="http://infinitecodex.com/image.axd?picture=image_2.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://infinitecodex.com/image.axd?picture=image_thumb_2.png" width="644" height="209" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;That will filter the results to all files within those ranges.&amp;#160; This even works on Server 2008 (I thought it was a Windows 7 only feature at first).&lt;/p&gt;  &lt;h2&gt;Search in Internet Explorer Favorites&lt;/h2&gt;  &lt;p&gt;You can also search through your internet bookmarks and favorites by the strange sequence of adding your favorites to the favorites for search.&lt;/p&gt;  &lt;p&gt;Step 1&lt;/p&gt;  &lt;p&gt;First navigate to your favorites folder in Explorer.&amp;#160; This should be the one under your username, not the one at the top of the Explorer window.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://infinitecodex.com/image.axd?picture=image_3.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="Choose Favorites" border="0" alt="Choose the favorites icon under your username" src="http://infinitecodex.com/image.axd?picture=image_thumb_3.png" width="342" height="267" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Select the Favorites item.&amp;#160; You will see your folders and bookmarks on the right side of the screen.&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;h2&gt;Step 2&lt;/h2&gt;  &lt;p&gt;Then you have to find the Favorites item that is usually at the very top on the left pane of Explorer.&amp;#160; DON’T CLICK IT.&amp;#160; Right Click and select &lt;strong&gt;&lt;em&gt;Add current location to Favorites&lt;/em&gt;&lt;/strong&gt;.&amp;#160; Then you will have a Favorites folder under the Favorites item.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://infinitecodex.com/image.axd?picture=image_4.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="Add current location to favorites" border="0" alt="Add current location to favorites" src="http://infinitecodex.com/image.axd?picture=image_thumb_4.png" width="332" height="209" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;That’s it.&amp;#160; You can now search them quickly and easily from the Explorer window.&lt;/p&gt;  &lt;h2&gt;Search the Internet Bookmarks and Favorites&lt;/h2&gt;  &lt;p&gt;This next part is also a little non intuitive to me.&amp;#160; To search the internet bookmark favorites you have to select the Favorites icon, then choose Favorites again (for the internet ones) and type your search in the &lt;strong&gt;upper right &lt;/strong&gt;corner of Explorer.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://infinitecodex.com/image.axd?picture=image_5.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="Search Favorites" border="0" alt="Search from upper right corner of Explorer" src="http://infinitecodex.com/image.axd?picture=image_thumb_5.png" width="644" height="207" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;h2&gt;Name your bookmarks when adding them&lt;/h2&gt;  &lt;p&gt;You can add a favorite by pressing Alt-Z on the keyboard while on a site, or hit the Star icon (Internet Explorer 9) and then add to favorites.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://infinitecodex.com/image.axd?picture=image_6.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://infinitecodex.com/image.axd?picture=image_thumb_6.png" width="244" height="113" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;I find this incredibly useful for finding my bookmarks later. I actually now take the time to give meaningful names to all my bookmarks so I can search on them later. No content from the page can be searched, just the title you put in the bookmark, and the web address.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://infinitecodex.com/image.axd?picture=image_7.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://infinitecodex.com/image.axd?picture=image_thumb_7.png" width="456" height="212" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;You can also create folders for them as well.&lt;/p&gt;  &lt;h2&gt;Sync your bookmarks across machines&lt;/h2&gt;  &lt;p&gt;Did you know you can keep your bookmarks across multiple machines?&lt;/p&gt;  &lt;p&gt;Using &lt;a href="http://explore-df.live.com/windows-live-mesh"&gt;Windows Live Mesh&lt;/a&gt; you only have to select to Sync your Internet Explorer under Program Settings.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://infinitecodex.com/image.axd?picture=image_8.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://infinitecodex.com/image.axd?picture=image_thumb_8.png" width="644" height="94" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Windows Live Mesh is a free tool that allows you to also sync folders across machines as well.&amp;#160; If you haven’t seen this tool you really need to!&amp;#160; I think it is way better than using a third party service like Drop Box.&amp;#160; I use it to sync One Note notebooks across all my machines.&lt;/p&gt;  &lt;p&gt;Hope this helps someone, and now I won’t forget it either. &lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/Vistadb?a=ac2zXX7MEXE:DJ8uXjlaHJA:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Vistadb?i=ac2zXX7MEXE:DJ8uXjlaHJA:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Vistadb?a=ac2zXX7MEXE:DJ8uXjlaHJA:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Vistadb?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Vistadb?a=ac2zXX7MEXE:DJ8uXjlaHJA:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Vistadb?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/Vistadb/~4/ac2zXX7MEXE" height="1" width="1"/&gt;</description>
      <link>http://feedproxy.google.com/~r/Vistadb/~3/ac2zXX7MEXE/post.aspx</link>
      <author>jasonshort@infinitecodex.com</author>
      <comments>http://infinitecodex.com/infinitecodex/post/2011/12/06/Explorer-Search-options-for-file-and-IE-favorites.aspx#comment</comments>
      <guid isPermaLink="false">http://infinitecodex.com/infinitecodex/post.aspx?id=1d0acc69-9681-4239-be1d-16dcce4be8bd</guid>
      <pubDate>Tue, 06 Dec 2011 00:56:00 -1500</pubDate>
      <category>General</category>
      <dc:publisher>jshort</dc:publisher>
      <pingback:server>http://infinitecodex.com/infinitecodex/pingback.axd</pingback:server>
      <pingback:target>http://infinitecodex.com/infinitecodex/post.aspx?id=1d0acc69-9681-4239-be1d-16dcce4be8bd</pingback:target>
      <slash:comments>0</slash:comments>
      <trackback:ping>http://infinitecodex.com/infinitecodex/trackback.axd?id=1d0acc69-9681-4239-be1d-16dcce4be8bd</trackback:ping>
      <wfw:comment>http://infinitecodex.com/infinitecodex/post/2011/12/06/Explorer-Search-options-for-file-and-IE-favorites.aspx#comment</wfw:comment>
      <wfw:commentRss>http://infinitecodex.com/infinitecodex/syndication.axd?post=1d0acc69-9681-4239-be1d-16dcce4be8bd</wfw:commentRss>
    <feedburner:origLink>http://infinitecodex.com/infinitecodex/post.aspx?id=1d0acc69-9681-4239-be1d-16dcce4be8bd</feedburner:origLink></item>
    <item>
      <title>Async Data Flow Block in TPL</title>
      <description>&lt;p&gt;Check out the new System.Threading.Tasks.Dataflow.dll for processing blocks of data in an asynchronous manner.&amp;#160; I watched this video on Channel 9 and it blew me away.&amp;#160; I hope this goes into .Net 4.5 by default.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.microsoft.com/download/en/details.aspx?displaylang=en&amp;amp;id=14782" target="_blank"&gt;Intro to TPL Dataflow&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Very easy to control things like a data pump where you want to process the data as it comes into a queue.&amp;#160; You can even let the ActionBlock run in and just have it call you back when it is done.&lt;/p&gt; &lt;iframe style="width: 512px; height: 288px" src="http://channel9.msdn.com/posts/TPL-Dataflow-Tour/player?w=512&amp;amp;h=288" frameborder="0" scrolling="no"&gt;&lt;/iframe&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h2&gt;Sample code&lt;/h2&gt;  &lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; direction: ltr; max-height: 400px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;   &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: #008000"&gt;// Setup an action block - nothing is happening here &lt;/span&gt;&lt;br /&gt;&lt;span style="color: #008000"&gt;// until we post something to this block&lt;/span&gt;&lt;br /&gt;var ab = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; ActionBlock&amp;lt;&lt;span style="color: #0000ff"&gt;int&lt;/span&gt;&amp;gt;( i =&amp;gt;&lt;br /&gt;{&lt;br /&gt;    &lt;span style="color: #008000"&gt;// Wait without blocking the thread&lt;/span&gt;&lt;br /&gt;    await TaskEx.Delay(1000);&lt;br /&gt;    Console.WriteLine(i);&lt;br /&gt;}&lt;br /&gt;, &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; DataFlowBlockOptions(TaskScheduler.Default, 4));&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: #008000"&gt;// Now post 10 items to the block&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #0000ff"&gt;for&lt;/span&gt;(&lt;span style="color: #0000ff"&gt;int&lt;/span&gt; i = 0; i &amp;lt; 10; i++)&lt;br /&gt;{&lt;br /&gt;    ab.Post(i);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span style="color: #008000"&gt;// Tell the action block we are done and it should stop&lt;/span&gt;&lt;br /&gt;ab.DeclinePermanently();&lt;br /&gt;&lt;br /&gt;&lt;span style="color: #008000"&gt;// Wait for it to done processing&lt;/span&gt;&lt;br /&gt;ab.CompletionTask.Wait();&lt;/pre&gt;

  &lt;br /&gt;&lt;/div&gt;

&lt;h2&gt;More information&lt;/h2&gt;

&lt;p&gt;&lt;a href="http://msdn.microsoft.com/en-us/vstudio/async" target="_blank"&gt;Visual Studio Aync Website&lt;/a&gt;&lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/Vistadb?a=b4ijnKzQp7k:j54uM5z1iXo:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Vistadb?i=b4ijnKzQp7k:j54uM5z1iXo:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Vistadb?a=b4ijnKzQp7k:j54uM5z1iXo:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Vistadb?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Vistadb?a=b4ijnKzQp7k:j54uM5z1iXo:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Vistadb?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/Vistadb/~4/b4ijnKzQp7k" height="1" width="1"/&gt;</description>
      <link>http://feedproxy.google.com/~r/Vistadb/~3/b4ijnKzQp7k/post.aspx</link>
      <author>jasonshort@infinitecodex.com</author>
      <comments>http://infinitecodex.com/infinitecodex/post/2011/11/16/Async-Data-Flow-Block-in-TPL.aspx#comment</comments>
      <guid isPermaLink="false">http://infinitecodex.com/infinitecodex/post.aspx?id=f6ade2bc-f0f8-4c1f-ae32-01bf18059498</guid>
      <pubDate>Wed, 16 Nov 2011 03:47:26 -1500</pubDate>
      <category>General</category>
      <dc:publisher>jshort</dc:publisher>
      <pingback:server>http://infinitecodex.com/infinitecodex/pingback.axd</pingback:server>
      <pingback:target>http://infinitecodex.com/infinitecodex/post.aspx?id=f6ade2bc-f0f8-4c1f-ae32-01bf18059498</pingback:target>
      <slash:comments>0</slash:comments>
      <trackback:ping>http://infinitecodex.com/infinitecodex/trackback.axd?id=f6ade2bc-f0f8-4c1f-ae32-01bf18059498</trackback:ping>
      <wfw:comment>http://infinitecodex.com/infinitecodex/post/2011/11/16/Async-Data-Flow-Block-in-TPL.aspx#comment</wfw:comment>
      <wfw:commentRss>http://infinitecodex.com/infinitecodex/syndication.axd?post=f6ade2bc-f0f8-4c1f-ae32-01bf18059498</wfw:commentRss>
    <feedburner:origLink>http://infinitecodex.com/infinitecodex/post.aspx?id=f6ade2bc-f0f8-4c1f-ae32-01bf18059498</feedburner:origLink></item>
    <item>
      <title>Windows Runtime Information Links</title>
      <description>&lt;p&gt;WINRT (as the Windows Runtime as been dubbed) was announced a while back at BUILD in California.&amp;#160; I was super busy at the time and didn’t get to read or watch any of the sessions online.&amp;#160; Check out the &lt;a href="http://en.wikipedia.org/wiki/WinRT" target="_blank"&gt;WinRT Wikipedia page&lt;/a&gt; for more information.&lt;/p&gt;  &lt;p&gt;I have been listening to podcasts and trying to catch up today while I am home sick.&amp;#160; Thought I would put some good links up for others looking to catch up also (and hopefully not while sick).&lt;/p&gt;  &lt;h2&gt;Dot Net Rocks&lt;/h2&gt;  &lt;p&gt;If you have never listened to &lt;a href="http://www.dotnetrocks.com/Default.aspx" target="_blank"&gt;Dot Net Rocks&lt;/a&gt; you seriously owe it to yourself to check it out.&amp;#160; I don’t listen to every show.&amp;#160; Grab ones you are interested in from their &lt;a href="http://www.dotnetrocks.com/archives.aspx" target="_blank"&gt;archive&lt;/a&gt;.&amp;#160; I have pointed several junior developers to their shows on specific topics and many have come back to tell me that the podcast was just enough to get them unstuck on some concept or idea.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.dotnetrocks.com/default.aspx?showNum=701" target="_blank"&gt;DNR Show 701&lt;/a&gt; has a really good intro where Carl goes through the WINRT and announcements from BUILD.&amp;#160; Listen to the first 15 minutes for the best information I have found anywhere about WINRT and Windows 8.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.dotnetrocks.com/default.aspx?showNum=705" target="_blank"&gt;DNR Show 705&lt;/a&gt; is an entire show about WINRT and WIN8.&amp;#160; It appears they will be starting a new podcast specifically about tablet development.&amp;#160; Rockford Lhotka and Billy Hollis are the guests on the show and talk about how they view WIN8 from a business and development standpoint.&amp;#160; Good information and will give you some insight into how WIN8 might win over the business segment.&lt;/p&gt;  &lt;h2&gt;Channel 9&lt;/h2&gt;  &lt;p&gt;&lt;a href="http://channel9.msdn.com/Events/BUILD/BUILD2011/TOOL-531T" target="_blank"&gt;Using the Windows Runtime from C# and Visual Basic&lt;/a&gt; BUILD session covering the topic at a high level.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.infoq.com/news/2011/09/Design-Details-Windows-Runtime;jsessionid=1BAFB234165E0EE562C6EB0AE2CB9C66"&gt;Design Details of the Windows Runtime&lt;/a&gt; has a good overview slide from BUILD showing how .Net and WinRT all work through the same stack in Windows 8.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.microsoft.co.il/blogs/sasha/archive/2011/09/15/winrt-and-net-in-windows-8.aspx" target="_blank"&gt;WinRT and .NET in Windows 8&lt;/a&gt; a good blog post about the rumors of .Nets death being greatly exaggerated. &lt;/p&gt;  &lt;p&gt;&lt;a href="http://channel9.msdn.com/Shows/Going+Deep/Bart-De-Smet-Rx-Updat-NET-45-Async-WinRT" target="_blank"&gt;.Net 4.5, Async, WinRT with Bart De Smet&lt;/a&gt; is a video podcast talking about some topics for all .Net developers in the coming months and years.&amp;#160; Bart is a seriously smart Microsoft engineer working on all sorts of async technologies.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://channel9.msdn.com/Shows/Going+Deep/Drawbridge-An-Experimental-Library-Operating-System" target="_blank"&gt;Application Virtualization&lt;/a&gt; is a great podcast talking about how apps could be sandboxed in a future OS.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://channel9.msdn.com/Shows/C9-GoingNative/GoingNative-2-C-at-BUILD-Windows-Runtime-LibraryWRL-Meet-Tarek-and-Sridhar" target="_blank"&gt;Going Native 2&lt;/a&gt; talks about using C++ in Windows 8 and how the runtime allows C++ to be a first class citizen of the OS again.&amp;#160; If you extrapolate a little you will also see how it was possible for Javascript to become first class as well.&lt;/p&gt;  &lt;h2&gt;Metro is coming&lt;/h2&gt;  &lt;p&gt;Of course building Windows Phone 7 apps I have seen the Metro UI for a while now.&amp;#160; But I am amazed at how many people are now jumping on the Metro theme.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.africangeek.com/"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto; padding-top: 0px" title="image" border="0" alt="image" src="http://infinitecodex.com/image.axd?picture=image_1.png" width="244" height="171" /&gt;&lt;/a&gt;One site that really took the look and feel of Metro and went all out is the &lt;a href="http://www.africangeek.com/" target="_blank"&gt;AfricanGeek.com&lt;/a&gt; site.It is written in Silverlight, but he nailed the whole Windows 8 look and feel for his site.&lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/Vistadb?a=-EE_nY3AWLY:HV1cXPuWcjA:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Vistadb?i=-EE_nY3AWLY:HV1cXPuWcjA:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Vistadb?a=-EE_nY3AWLY:HV1cXPuWcjA:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Vistadb?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Vistadb?a=-EE_nY3AWLY:HV1cXPuWcjA:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Vistadb?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/Vistadb/~4/-EE_nY3AWLY" height="1" width="1"/&gt;</description>
      <link>http://feedproxy.google.com/~r/Vistadb/~3/-EE_nY3AWLY/post.aspx</link>
      <author>jasonshort@infinitecodex.com</author>
      <comments>http://infinitecodex.com/infinitecodex/post/2011/10/19/Windows-Runtime-Information-Links.aspx#comment</comments>
      <guid isPermaLink="false">http://infinitecodex.com/infinitecodex/post.aspx?id=3a8c4d55-7862-4f90-a83e-a8418fafb319</guid>
      <pubDate>Wed, 19 Oct 2011 05:44:38 -1500</pubDate>
      <category>General</category>
      <dc:publisher>jshort</dc:publisher>
      <pingback:server>http://infinitecodex.com/infinitecodex/pingback.axd</pingback:server>
      <pingback:target>http://infinitecodex.com/infinitecodex/post.aspx?id=3a8c4d55-7862-4f90-a83e-a8418fafb319</pingback:target>
      <slash:comments>0</slash:comments>
      <trackback:ping>http://infinitecodex.com/infinitecodex/trackback.axd?id=3a8c4d55-7862-4f90-a83e-a8418fafb319</trackback:ping>
      <wfw:comment>http://infinitecodex.com/infinitecodex/post/2011/10/19/Windows-Runtime-Information-Links.aspx#comment</wfw:comment>
      <wfw:commentRss>http://infinitecodex.com/infinitecodex/syndication.axd?post=3a8c4d55-7862-4f90-a83e-a8418fafb319</wfw:commentRss>
    <feedburner:origLink>http://infinitecodex.com/infinitecodex/post.aspx?id=3a8c4d55-7862-4f90-a83e-a8418fafb319</feedburner:origLink></item>
    <item>
      <title>TouchDevelop makes Windows Phone 7 easy to program</title>
      <description>&lt;p&gt;I attended a great XAPFest meeting last night about &lt;a href="https://www.touchdevelop.com" target="_blank"&gt;TouchDevelop&lt;/a&gt;.&amp;nbsp; This is an app you can download today for your Windows Phone 7 from the &lt;a href="http://www.windowsphone.com/en-US/apps/fe08ccec-a360-e011-81d2-78e7d1fa76f8" target="_blank"&gt;Web Marketplace&lt;/a&gt;.&lt;/p&gt;
&lt;h2&gt;What is it?&lt;/h2&gt;
&lt;p&gt;&lt;img style="display: inline; float: right;" src="https://www.touchdevelop.com/images/5_TouchDevelop.png" alt="" width="300" height="500" align="right" /&gt;Many of us were introduced to programming because we had computers at home (and usually lots of free time).&amp;nbsp; Most machines had built in BASIC or some other language, and there were lots of magazines and books with code you could type in to make your machine do what you wanted.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Today most machines do not have a built in language, or tutorials on how to use the built in tools like Powershell to write programs.&amp;nbsp; Even then the tools and learning curve is very steep.&amp;nbsp; Learning to do something like post an image to Facebook means having to learn a LOT of different technologies.&lt;/p&gt;
&lt;p&gt;TouchDevelop is a very easy to use programming tool that lets users write applications directly on the phone.&amp;nbsp; No need to sync to a PC, or learn C# or even know the SDK.&amp;nbsp; All of the features of the phone are exposed through built in objects in the tool.&amp;nbsp; The user doesn&amp;rsquo;t have to know the difference between a JPG and a PNG.&amp;nbsp; They just say Image.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;h2&gt;Demo App to Randomly Play Songs&lt;/h2&gt;
&lt;p&gt;The demo I watched was building an app to randomly play songs.&amp;nbsp; If you have ever done this in C# you know this would take more than the 5 minutes it took with TouchDevelop.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;But then features were added like when you flip the phone face down it will stop or start the song.&amp;nbsp; That was added in seconds (not kidding).&lt;/p&gt;
&lt;p&gt;Want to pin this app to the home screen so you can quickly launch it?&amp;nbsp; Easy.&lt;/p&gt;
&lt;p&gt;Update the Pinned Tile to have a custom icon, show the album art, and the name of the song?&amp;nbsp; Easy.&amp;nbsp; As someone who as implemented this in an app I can tell you the TouchDevelop approach is WAY easier than doing it in C#!&lt;/p&gt;
&lt;h2&gt;XAPFest Expanded&lt;/h2&gt;
&lt;p&gt;So I took the XAPFest demo from last night and expanded it to include some new features.&amp;nbsp; All scripts can be published up to the script bazaar on the TouchDevelop website.&lt;/p&gt;
&lt;p&gt;Here is the version I pushed up this morning:&amp;nbsp; &lt;a href="https://www.touchdevelop.com/oeag"&gt;https://www.touchdevelop.com/oeag&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Notice that this shows the other related scripts, screenshots, the full script code and more.&amp;nbsp; All your apps can be pushed to the cloud for backup, and for sharing.&amp;nbsp; Others can even write reviews and post their own screen shots.&amp;nbsp; This is starting to feel a lot like an extension to the marketplace.&lt;/p&gt;
&lt;p&gt;So I wanted to add a few features to the original demo.&amp;nbsp; Shake to choose a new random song.&amp;nbsp; Count of the number of songs that have been played using the app, and show that on the live tile as the counter.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;How long did this take?&amp;nbsp; I timed myself.&amp;nbsp; Having zero experience with TouchDevelop, other than the one demo last night, it took 4 minutes and 35 seconds.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;event shake() { code&amp;rarr;choose_random_song; code&amp;rarr;update_tile(data&amp;rarr;song); meta private; }&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Added a totalPlayed global variable that is updated everytime a new song is chosen like this.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;data&amp;rarr;totalPlayed := data&amp;rarr;totalPlayed + 1;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;The best part is that I did it all on the phone, and published the update so others could see it too.&lt;/p&gt;
&lt;p&gt;&lt;img src="https://az31353.vo.msecnd.net/pub/iskm" alt="" /&gt;&lt;/p&gt;
&lt;h2&gt;Education and Entertainment&lt;/h2&gt;
&lt;p&gt;I firmly believe that people learn WAY more when they are entertained during education.&amp;nbsp; Anyone building an app will find the sheer joy of controlling their phone a lot of fun.&amp;nbsp; And the interface makes it really easy to discover what can be done through the UI, and through the other scripts you can download and inspect.&lt;/p&gt;
&lt;h2&gt;More Information&lt;/h2&gt;
&lt;p&gt;&lt;a href="http://channel9.msdn.com/Blogs/Peli/TouchStudio-Script-Your-Phone-ON-Your-Phone" target="_blank"&gt;Script your phone on your phone&lt;/a&gt; (Channel 9)&lt;/p&gt;
&lt;p&gt;&lt;a href="http://channel9.msdn.com/Blogs/Peli/TouchStudio-Hello-World" target="_blank"&gt;Hello World with TouchDevelop&lt;/a&gt; (Channel 9)&lt;/p&gt;
&lt;p&gt;&lt;a href="http://socialtimes.com/microsoft-touchdevelop-2-2-for-windows-phone-make-your-own-apps_b78488" target="_blank"&gt;TouchDevelop 2.2 Make Your Own Apps&lt;/a&gt; (SocialTimes.com)&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.msdn.com/b/nikolait/archive/2011/10/07/touchdevelop-v2-3-for-mango-pin-to-start-for-scripts.aspx" target="_blank"&gt;Pin to Start in Mango&lt;/a&gt; (Nikolai Tillman Blog)&lt;/p&gt;
&lt;h3&gt;Updated&lt;/h3&gt;
&lt;p&gt;&lt;a href="http://research.microsoft.com/apps/video/default.aspx?id=155338"&gt;Recording from XAPFest Presentation&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;The recording from the actual presentation I attended was posted online, so I wanted to share the link.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/Vistadb?a=rmoxXL2CGWQ:-VlmMuws0Tc:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Vistadb?i=rmoxXL2CGWQ:-VlmMuws0Tc:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Vistadb?a=rmoxXL2CGWQ:-VlmMuws0Tc:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Vistadb?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Vistadb?a=rmoxXL2CGWQ:-VlmMuws0Tc:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Vistadb?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/Vistadb/~4/rmoxXL2CGWQ" height="1" width="1"/&gt;</description>
      <link>http://feedproxy.google.com/~r/Vistadb/~3/rmoxXL2CGWQ/post.aspx</link>
      <author>jasonshort@infinitecodex.com</author>
      <comments>http://infinitecodex.com/infinitecodex/post/2011/10/14/TouchDevelop-makes-Windows-Phone-7-easy-to-program.aspx#comment</comments>
      <guid isPermaLink="false">http://infinitecodex.com/infinitecodex/post.aspx?id=fa9603c0-09b1-4ab0-ad02-4bf4354b4806</guid>
      <pubDate>Fri, 14 Oct 2011 04:09:00 -1500</pubDate>
      <category>WP7</category>
      <dc:publisher>jshort</dc:publisher>
      <pingback:server>http://infinitecodex.com/infinitecodex/pingback.axd</pingback:server>
      <pingback:target>http://infinitecodex.com/infinitecodex/post.aspx?id=fa9603c0-09b1-4ab0-ad02-4bf4354b4806</pingback:target>
      <slash:comments>0</slash:comments>
      <trackback:ping>http://infinitecodex.com/infinitecodex/trackback.axd?id=fa9603c0-09b1-4ab0-ad02-4bf4354b4806</trackback:ping>
      <wfw:comment>http://infinitecodex.com/infinitecodex/post/2011/10/14/TouchDevelop-makes-Windows-Phone-7-easy-to-program.aspx#comment</wfw:comment>
      <wfw:commentRss>http://infinitecodex.com/infinitecodex/syndication.axd?post=fa9603c0-09b1-4ab0-ad02-4bf4354b4806</wfw:commentRss>
    <feedburner:origLink>http://infinitecodex.com/infinitecodex/post.aspx?id=fa9603c0-09b1-4ab0-ad02-4bf4354b4806</feedburner:origLink></item>
    <item>
      <title>Create new SQL Azure database as a copy</title>
      <description>&lt;p&gt;Did you know you can create a new SQL Azure database as a copy of an existing database?&amp;#160; Yes, you can.&amp;#160; There are some important limitations on how this works which I will cover below.&amp;#160;&amp;#160; &lt;/p&gt;  &lt;h2&gt;Create the new database&lt;/h2&gt;  &lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;   &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: #008000"&gt;-- create a new database as a copy&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #0000ff"&gt;create&lt;/span&gt; &lt;span style="color: #0000ff"&gt;database&lt;/span&gt; new_database &lt;span style="color: #0000ff"&gt;as&lt;/span&gt; copy &lt;span style="color: #0000ff"&gt;of&lt;/span&gt; original_database&lt;/pre&gt;

  &lt;br /&gt;&lt;/div&gt;

&lt;p&gt;In order to do this you must be logged in as the DBO of the original database.&amp;#160; See the NOTE in the article as well.&amp;#160; I think this is important difference for most database apps, the logins that are contained in the database must be updated.&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt; After the cross-server copy process is complete, use the DBO login and the &lt;code&gt;ALTER USER&lt;/code&gt; statement to map users in the new database to logins on the new SQL Azure server. For example: &lt;code&gt;ALTER USER userName WITH LOGIN='loginName'&lt;/code&gt;. For more information, see &lt;a href="http://msdn.microsoft.com/en-us/library/ee336234.aspx"&gt;ALTER USER (SQL Azure Database)&lt;/a&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;/p&gt;

&lt;h2&gt;How do you know when it is done?&lt;/h2&gt;

&lt;p&gt;Now that’s great you started the copy, but how do you know when it is done?&amp;#160; There is TSQL syntax for that!&lt;/p&gt;

&lt;p&gt;You can query the state from the sys.databases table to get the text like this:&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: #0000ff"&gt;select&lt;/span&gt; name, &lt;span style="color: #0000ff"&gt;state&lt;/span&gt;, state_desc &lt;span style="color: #0000ff"&gt;from&lt;/span&gt; sys.databases &lt;span style="color: #0000ff"&gt;where&lt;/span&gt; name = &lt;span style="color: #006080"&gt;'new_database'&lt;/span&gt;&lt;/pre&gt;

  &lt;br /&gt;&lt;/div&gt;

&lt;p&gt;You will get back a response that should look like this:&lt;/p&gt;

&lt;table border="0" cellspacing="0" cellpadding="2" width="400"&gt;&lt;tbody&gt;
    &lt;tr&gt;
      &lt;td valign="top" width="133"&gt;&lt;strong&gt;name&lt;/strong&gt;&lt;/td&gt;

      &lt;td valign="top" width="133"&gt;&lt;strong&gt;state&lt;/strong&gt;&lt;/td&gt;

      &lt;td valign="top" width="133"&gt;&lt;strong&gt;state_desc&lt;/strong&gt;&lt;/td&gt;
    &lt;/tr&gt;

    &lt;tr&gt;
      &lt;td valign="top" width="133"&gt;new_database&lt;/td&gt;

      &lt;td valign="top" width="133"&gt;7&lt;/td&gt;

      &lt;td valign="top" width="133"&gt;COPYING&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;&lt;/table&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;h2&gt;Copy Progress&lt;/h2&gt;

&lt;p&gt;According to &lt;a href="http://msdn.microsoft.com/en-us/library/ff951634.aspx" target="_blank"&gt;this MSDN Article&lt;/a&gt; you can also get the state while the COPYING is happening by querying sys.dm_database_copies. But there is a catch. Once the copy completes the rows are automatically removed, so be prepared to get nothing back. Even if you just got the COPYING above, there seems to be a slight lag where the dm_database_copies rows are removed before the sys.database entries are updated.&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: #0000ff"&gt;select&lt;/span&gt; * &lt;span style="color: #0000ff"&gt;from&lt;/span&gt; sys.dm_database_copies &lt;span style="color: #0000ff"&gt;where&lt;/span&gt; database_id = DB_ID(&lt;span style="color: #006080"&gt;'new_database'&lt;/span&gt;)&lt;/pre&gt;

  &lt;br /&gt;&lt;/div&gt;

&lt;p&gt;That actually doesn’t work because the DB_ID will return NULL (the database doesn’t exist yet).&lt;/p&gt;

&lt;p&gt;But just running the select without the where gives you something like this:&lt;/p&gt;

&lt;table border="0" cellspacing="0" cellpadding="2"&gt;&lt;tbody&gt;
    &lt;tr&gt;
      &lt;td valign="top" width="50"&gt;database_id&lt;/td&gt;

      &lt;td valign="top" width="102"&gt;start_date&lt;/td&gt;

      &lt;td valign="top" width="39"&gt;modify_date&lt;/td&gt;

      &lt;td valign="top" width="10"&gt;percent_complete&lt;/td&gt;

      &lt;td valign="top" width="50"&gt;error_code&lt;/td&gt;

      &lt;td valign="top" width="50"&gt;error_desc&lt;/td&gt;

      &lt;td valign="top" width="50"&gt;error_severity&lt;/td&gt;

      &lt;td valign="top" width="50"&gt;error_state&lt;/td&gt;
    &lt;/tr&gt;

    &lt;tr&gt;
      &lt;td valign="top" width="50"&gt;6&lt;/td&gt;

      &lt;td valign="top" width="102"&gt;10/5/2011 4:30:12 PM +00:00&lt;/td&gt;

      &lt;td valign="top" width="39"&gt;10/5/2011 4:30:12 PM +00:00&lt;/td&gt;

      &lt;td valign="top" width="10"&gt;null&lt;/td&gt;

      &lt;td valign="top" width="50"&gt;null&lt;/td&gt;

      &lt;td valign="top" width="50"&gt;null&lt;/td&gt;

      &lt;td valign="top" width="50"&gt;null&lt;/td&gt;

      &lt;td valign="top" width="50"&gt;null&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;&lt;/table&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;I have never seen the percent_complete change, or any of the error states be filled out (even when there was an error).&amp;#160; So I don’t know if this is intended to change in the future to be completed, or was removed.&lt;/p&gt;

&lt;p&gt;The &lt;a href="http://msdn.microsoft.com/en-us/library/ff951634.aspx" target="_blank"&gt;dm_database_copies MSDN page&lt;/a&gt; says that the information is only available on the master database context.&lt;/p&gt;

&lt;h2&gt;MSDN References&lt;/h2&gt;

&lt;p&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/ff951624.aspx" target="_blank"&gt;Copying Databases in Sql Azure&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/ff951634.aspx" target="_blank"&gt;sys.dm_database_copies in SQL Azure&lt;/a&gt;&lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/Vistadb?a=i2ebjxTil0E:Bo33Ncb06Os:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Vistadb?i=i2ebjxTil0E:Bo33Ncb06Os:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Vistadb?a=i2ebjxTil0E:Bo33Ncb06Os:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Vistadb?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Vistadb?a=i2ebjxTil0E:Bo33Ncb06Os:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Vistadb?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/Vistadb/~4/i2ebjxTil0E" height="1" width="1"/&gt;</description>
      <link>http://feedproxy.google.com/~r/Vistadb/~3/i2ebjxTil0E/post.aspx</link>
      <author>jasonshort@infinitecodex.com</author>
      <comments>http://infinitecodex.com/infinitecodex/post/2011/10/05/Create-new-SQL-Azure-database-as-a-copy.aspx#comment</comments>
      <guid isPermaLink="false">http://infinitecodex.com/infinitecodex/post.aspx?id=8e054e16-15c5-4be1-b2df-776e314626c8</guid>
      <pubDate>Wed, 05 Oct 2011 01:49:49 -1500</pubDate>
      <category>Database Related</category>
      <dc:publisher>jshort</dc:publisher>
      <pingback:server>http://infinitecodex.com/infinitecodex/pingback.axd</pingback:server>
      <pingback:target>http://infinitecodex.com/infinitecodex/post.aspx?id=8e054e16-15c5-4be1-b2df-776e314626c8</pingback:target>
      <slash:comments>0</slash:comments>
      <trackback:ping>http://infinitecodex.com/infinitecodex/trackback.axd?id=8e054e16-15c5-4be1-b2df-776e314626c8</trackback:ping>
      <wfw:comment>http://infinitecodex.com/infinitecodex/post/2011/10/05/Create-new-SQL-Azure-database-as-a-copy.aspx#comment</wfw:comment>
      <wfw:commentRss>http://infinitecodex.com/infinitecodex/syndication.axd?post=8e054e16-15c5-4be1-b2df-776e314626c8</wfw:commentRss>
    <feedburner:origLink>http://infinitecodex.com/infinitecodex/post.aspx?id=8e054e16-15c5-4be1-b2df-776e314626c8</feedburner:origLink></item>
  </channel>
</rss>

