<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://weblogs.asp.net/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Dan Wahlin&amp;#39;s WebLog</title><link>http://weblogs.asp.net/dwahlin/default.aspx</link><description>ASP.NET, AJAX, Silverlight, XML, and Web Services Exploration</description><dc:language>en</dc:language><generator>CommunityServer 2007 SP1 (Build: 20510.895)</generator><item><title>My Latest Silverlight Articles</title><link>http://weblogs.asp.net/dwahlin/archive/2008/07/22/my-latest-silverlight-articles.aspx</link><pubDate>Wed, 23 Jul 2008 04:19:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:4346912</guid><dc:creator>dwahlin</dc:creator><slash:comments>24</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/dwahlin/rsscomments.aspx?PostID=4346912</wfw:commentRss><comments>http://weblogs.asp.net/dwahlin/archive/2008/07/22/my-latest-silverlight-articles.aspx#comments</comments><description>&lt;p&gt;Over the past few months I've been writing articles for the &lt;a href="http://www.ftponline.com/" target="_blank" mce_href="http://www.ftponline.com/"&gt;&lt;u&gt;&lt;font style="color: #0066cc" color="#0066cc"&gt;.NET Insight&lt;/font&gt;&lt;/u&gt;&lt;/a&gt; insight newsletter covering various ASP.NET AJAX concepts.&amp;#160; You can &lt;a href="http://weblogs.asp.net/dwahlin/archive/2007/09/18/latest-asp-net-ajax-articles.aspx" target="_blank" mce_href="http://weblogs.asp.net/dwahlin/archive/2007/09/18/latest-asp-net-ajax-articles.aspx"&gt;&lt;u&gt;&lt;font style="color: #0066cc" color="#0066cc"&gt;read those article here&lt;/font&gt;&lt;/u&gt;&lt;/a&gt;.&amp;#160; I've wrapped up that series and have started writing about Silverlight 1.0.&amp;#160; Each week (or so) a new article will be published and I'll update them here so check back.&amp;#160; The articles are designed to be focused and concise and get straight to the topic without a lot of fluff.&amp;#160; &lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;     &lt;div&gt;&lt;a href="http://www.ftponline.com/channels/net/2007_10/dwahlin/" target="_blank" mce_href="http://www.ftponline.com/channels/net/2007_10/dwahlin/"&gt;&lt;font style="color: #0066cc" color="#0066cc"&gt;&lt;u&gt;Getting Started with Silverlight&lt;/u&gt;&lt;/font&gt;&lt;/a&gt;&lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div&gt;&lt;a href="http://www.ftponline.com/channels/net/2007_10/dwahlin2/" target="_blank" mce_href="http://www.ftponline.com/channels/net/2007_10/dwahlin2/"&gt;&lt;font style="color: #0066cc" color="#0066cc"&gt;&lt;u&gt;Using Microsoft's Silverlight Control in a Web Site&lt;/u&gt;&lt;/font&gt;&lt;/a&gt;&lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div&gt;&lt;a href="http://www.ftponline.com/channels/net/2007_10/dwahlin3/" target="_blank" mce_href="http://www.ftponline.com/channels/net/2007_10/dwahlin3/"&gt;&lt;font style="color: #0066cc" color="#0066cc"&gt;&lt;u&gt;Understanding Silverlight's createObject and createObjectEx Methods&lt;/u&gt;&lt;/font&gt;&lt;/a&gt;&lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div&gt;&lt;a href="http://visualstudiomagazine.com/columns/article.aspx?editorialsid=2374" target="_blank" mce_href="http://visualstudiomagazine.com/columns/article.aspx?editorialsid=2374"&gt;&lt;font style="color: #800080" color="#800080"&gt;&lt;u&gt;Silverlight XAML Primer 1: Exploring Canvases&lt;/u&gt;&lt;/font&gt;&lt;/a&gt;&lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div&gt;&lt;a href="http://visualstudiomagazine.com/columns/article.aspx?editorialsid=2402" target="_blank" mce_href="http://visualstudiomagazine.com/columns/article.aspx?editorialsid=2402"&gt;&lt;font style="color: #800080" color="#800080"&gt;&lt;u&gt;Silverlight XAML Primer 2: Rectangles, Ellipses, Lines and Text&lt;/u&gt;&lt;/font&gt;&lt;/a&gt;&lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div&gt;&lt;a href="http://visualstudiomagazine.com/columns/article.aspx?editorialsid=2409" target="_blank" mce_href="http://visualstudiomagazine.com/columns/article.aspx?editorialsid=2409"&gt;&lt;u&gt;&lt;font style="color: #800080" color="#800080"&gt;Silverlight XAML Primer 3: Working with Image Brushes&lt;/font&gt;&lt;/u&gt;&lt;/a&gt;&lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div&gt;&lt;a href="http://visualstudiomagazine.com/columns/article.aspx?editorialsid=2417" target="_blank" mce_href="http://visualstudiomagazine.com/columns/article.aspx?editorialsid=2417"&gt;&lt;u&gt;&lt;font style="color: #0066cc" color="#0066cc"&gt;Silverlight XAML Primer 4: Working with Linear Gradients&lt;/font&gt;&lt;/u&gt;&lt;/a&gt;&amp;#160;&lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div&gt;&lt;a href="http://visualstudiomagazine.com/columns/article.aspx?editorialsid=2449" target="_blank" mce_href="http://visualstudiomagazine.com/columns/article.aspx?editorialsid=2449"&gt;&lt;u&gt;&lt;font style="color: #800080" color="#800080"&gt;Silverlight XAML Primer 5: Working with Radial Gradients&lt;/font&gt;&lt;/u&gt;&lt;/a&gt;&amp;#160;&lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div&gt;&lt;a href="http://visualstudiomagazine.com/columns/article.aspx?editorialsid=2455" target="_blank" mce_href="http://visualstudiomagazine.com/columns/article.aspx?editorialsid=2455"&gt;&lt;font style="color: #800080" color="#800080"&gt;&lt;u&gt;Silverlight XAML Primer 6: Using Inline XAML with Silverlight&lt;/u&gt;&lt;/font&gt;&lt;/a&gt;&lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div&gt;&lt;a href="http://visualstudiomagazine.com/columns/article.aspx?editorialsid=2474" target="_blank" mce_href="http://visualstudiomagazine.com/columns/article.aspx?editorialsid=2474"&gt;&lt;u&gt;&lt;font style="color: #800080" color="#800080"&gt;Silverlight XAML Primer 7: Embedding Media into Silverlight&lt;/font&gt;&lt;/u&gt;&lt;/a&gt;&amp;#160;&lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div&gt;&lt;a class="" href="http://visualstudiomagazine.com/columns/article.aspx?editorialsid=2488" target="_blank" mce_href="http://visualstudiomagazine.com/columns/article.aspx?editorialsid=2488"&gt;Silverlight XAML Primer 8: Working with XAML Events&lt;/a&gt;&lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div&gt;&lt;a class="" href="http://visualstudiomagazine.com/columns/article.aspx?editorialsid=2514" target="_blank" mce_href="http://visualstudiomagazine.com/columns/article.aspx?editorialsid=2514"&gt;Silverlight XAML Primer 9: Using the Silverlight Downloader Object&lt;/a&gt;&lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div&gt;&lt;a class="" href="http://www.ddj.com/windows/206901111?cid=RSSfeed_DDJ_All" target="_blank" mce_href="http://www.ddj.com/windows/206901111?cid=RSSfeed_DDJ_All"&gt;Working with Events in Silverlight&lt;/a&gt; &lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div&gt;&lt;a class="" href="http://visualstudiomagazine.com/columns/article.aspx?editorialsid=2527" target="_blank" mce_href="http://visualstudiomagazine.com/columns/article.aspx?editorialsid=2527"&gt;Silverlight XAML Primer 10: Creating a Silverlight Downloader Progress Bar&lt;/a&gt;&lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div&gt;&lt;a class="" href="http://visualstudiomagazine.com/columns/article.aspx?editorialsid=2530" target="_blank" mce_href="http://visualstudiomagazine.com/columns/article.aspx?editorialsid=2530"&gt;Silverlight XAML Primer 11: Getting Started with Animations&lt;/a&gt;&amp;#160;&lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div&gt;&lt;a class="" href="http://visualstudiomagazine.com/columns/article.aspx?editorialsid=2556" target="_blank" mce_href="http://visualstudiomagazine.com/columns/article.aspx?editorialsid=2556"&gt;Silverlight XAML Primer 12: Using Linear Keyframe Animations&lt;/a&gt;&amp;#160;&lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div&gt;&lt;a class="" href="http://visualstudiomagazine.com/columns/article.aspx?editorialsid=2572" target="_blank" mce_href="http://visualstudiomagazine.com/columns/article.aspx?editorialsid=2572"&gt;Silverlight XAML Primer 13: Starting and Stopping Animations&lt;/a&gt; &lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div&gt;&lt;a class="" href="http://visualstudiomagazine.com/columns/article.aspx?editorialsid=2605" target="_blank" mce_href="http://visualstudiomagazine.com/columns/article.aspx?editorialsid=2605"&gt;Silverlight XAML Primer 14: Using Color Animations&lt;/a&gt; &lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div&gt;&lt;a class="" href="http://visualstudiomagazine.com/columns/article.aspx?editorialsid=2619" target="_blank" mce_href="http://visualstudiomagazine.com/columns/article.aspx?editorialsid=2619"&gt;Silverlight XAML Primer 15: Enhancing TextBlock with Runs and LineBreaks&lt;/a&gt;&lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div&gt;&lt;a class="" href="http://visualstudiomagazine.com/columns/article.aspx?editorialsid=2546" target="_blank" mce_href="http://visualstudiomagazine.com/columns/article.aspx?editorialsid=2546"&gt;Introducing Silverlight 2.0&lt;/a&gt;&lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div&gt;&lt;a class="" href="http://www.ddj.com/windows/207402928?cid=RSSfeed_DDJ_All" target="_blank" mce_href="http://www.ddj.com/windows/207402928?cid=RSSfeed_DDJ_All"&gt;Socket Support in Silverlight 2: Part I&lt;/a&gt; &lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div&gt;&lt;a class="" href="http://www.ddj.com/windows/207602773?cid=RSSfeed_DDJ_All" target="_blank" mce_href="http://www.ddj.com/windows/207602773?cid=RSSfeed_DDJ_All"&gt;Socket Support in Silverlight 2: Part II&lt;/a&gt; &lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div&gt;&lt;a class="" href="http://visualstudiomagazine.com/columns/article.aspx?editorialsid=2644" target="_blank" mce_href="http://visualstudiomagazine.com/columns/article.aspx?editorialsid=2644"&gt;Creating Your First Silverlight 2 Application&lt;/a&gt; &lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div&gt;&lt;a class="" href="http://visualstudiomagazine.com/columns/article.aspx?editorialsid=2669" target="_blank" mce_href="http://visualstudiomagazine.com/columns/article.aspx?editorialsid=2669"&gt;Getting Started with Silverlight 2 Controls&lt;/a&gt; &lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div&gt;&lt;a href="http://visualstudiomagazine.com/columns/article.aspx?editorialsid=2707" target="_blank"&gt;Using Silverlight 2 Layout Controls&lt;/a&gt; (New!)&lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div&gt;&lt;a class="" href="http://visualstudiomagazine.com/columns/article.aspx?editorialsid=2716" target="_blank" mce_href="http://visualstudiomagazine.com/columns/article.aspx?editorialsid=2716"&gt;Using the StackPanel Control&lt;/a&gt; (New !)&lt;/div&gt;   &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;A video of a talk I gave on integrating Silverlight with ASP.NET AJAX and Web Services can be &lt;a class="" href="http://weblogs.asp.net/dwahlin/archive/2008/01/20/new-video-integrating-silverlight-and-asp-net-ajax.aspx" target="_blank" mce_href="http://weblogs.asp.net/dwahlin/archive/2008/01/20/new-video-integrating-silverlight-and-asp-net-ajax.aspx"&gt;viewed here&lt;/a&gt; for those who are interested.&amp;#160; &lt;/p&gt;  &lt;p&gt;If you're interested in learning more about Silverlight 2.0 you can view &lt;a class="" href="http://weblogs.asp.net/dwahlin/archive/2008/03/07/silverlight-2-0-video-tutorials.aspx" target="_blank" mce_href="http://weblogs.asp.net/dwahlin/archive/2008/03/07/silverlight-2-0-video-tutorials.aspx"&gt;8 video tutorials that I put together here&lt;/a&gt;.&lt;/p&gt;  &lt;p mce_keep="true"&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Need to display OrgCharts, site maps or other hierarchies in your ASP.NET applications?&amp;#160; Check out &lt;a href="http://www.smartwebcontrols.com/" target="_blank"&gt;SmartChartPro&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.smartwebcontrols.com/" target="_blank"&gt;&lt;img src="http://www.smartwebcontrols.com/images/smartchartprologo.gif" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=4346912" width="1" height="1"&gt;</description></item><item><title>ASP.NET - Render Hidden Fields at the Top of a Form with .NET 3.5 SP1</title><link>http://weblogs.asp.net/dwahlin/archive/2008/07/22/asp-net-render-hidden-fields-at-the-top-of-a-form-with-net-3-5-sp1.aspx</link><pubDate>Tue, 22 Jul 2008 21:35:54 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6433278</guid><dc:creator>dwahlin</dc:creator><slash:comments>1</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/dwahlin/rsscomments.aspx?PostID=6433278</wfw:commentRss><comments>http://weblogs.asp.net/dwahlin/archive/2008/07/22/asp-net-render-hidden-fields-at-the-top-of-a-form-with-net-3-5-sp1.aspx#comments</comments><description>&lt;p&gt;&lt;/p&gt;  &lt;p&gt;I just came across a nice feature in ASP.NET 3.5 SP1 (currently in &lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=8C36ACA4-E947-4760-9B05-93CAC04C6F87&amp;amp;displaylang=en" target="_blank"&gt;Beta&lt;/a&gt;) that I didn’t realize was included.&amp;#160; It’s always nice to discover hidden gems from time to time.&amp;#160; With ASP.NET 1.0, 1.1, 2.0 and 3.5 applications if a user or JavaScript function tried to do a postback before all of the ViewState and EventValidation data was loaded in the browser, a ViewState MAC validation error could be raised by the server.&lt;/p&gt;  &lt;p&gt;In ASP.NET 3.5 SP1 Microsoft provides a new attribute on the &amp;lt;pages&amp;gt; element in web.config that now allows all hidden fields to be rendered at the top of a form rather than at the bottom which can help to avoid the ViewState MAC validation error when people perform a postback operation before the page has finished loading.&amp;#160; The attribute is named &lt;strong&gt;renderAllHiddenFieldsAtTopOfForm&lt;/strong&gt; (which does what it says) and defaults to a value of true.&amp;#160; .NET 3.5 SP1 is currently in beta but once it’s officially released the new attribute is definitely a nice enhancement to the ASP.NET framework.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Need to display OrgCharts, site maps or other hierarchies in your ASP.NET applications?&amp;#160; Check out &lt;a href="http://www.smartwebcontrols.com/"&gt;SmartChartPro&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.smartwebcontrols.com/"&gt;&lt;img src="http://www.smartwebcontrols.com/images/smartchartprologo.gif" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6433278" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/dwahlin/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/.NET/default.aspx">.NET</category></item><item><title>Instinct Experiment Over…Back to Windows Mobile</title><link>http://weblogs.asp.net/dwahlin/archive/2008/07/16/instinct-experiment-over-back-to-windows-mobile.aspx</link><pubDate>Wed, 16 Jul 2008 16:00:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6407197</guid><dc:creator>dwahlin</dc:creator><slash:comments>1</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/dwahlin/rsscomments.aspx?PostID=6407197</wfw:commentRss><comments>http://weblogs.asp.net/dwahlin/archive/2008/07/16/instinct-experiment-over-back-to-windows-mobile.aspx#comments</comments><description>&lt;P mce_keep="true"&gt;Over the past few weeks I’ve been trying out the &lt;A href="http://www.instinctthephone.com/?id12=UHP_Masthead_063008_instinctthephone" target=_blank mce_href="http://www.instinctthephone.com/?id12=UHP_Masthead_063008_instinctthephone"&gt;Sprint Instinct&lt;/A&gt; touch screen phone to see how I liked it.&amp;nbsp; I wrote my initial review &lt;A href="http://weblogs.asp.net/dwahlin/archive/2008/06/26/pros-and-cons-of-the-sprint-instinct-phone.aspx" target=_blank mce_href="http://weblogs.asp.net/dwahlin/archive/2008/06/26/pros-and-cons-of-the-sprint-instinct-phone.aspx"&gt;here&lt;/A&gt; and posted some tips and tricks on using the device &lt;A href="http://weblogs.asp.net/dwahlin/archive/2008/07/10/sprint-instinct-tips-and-tricks.aspx" target=_blank mce_href="http://weblogs.asp.net/dwahlin/archive/2008/07/10/sprint-instinct-tips-and-tricks.aspx"&gt;here&lt;/A&gt;.&amp;nbsp; The poor browsing experience on the Instinct finally led me to take it back to the store yesterday so I’m back to using my PPC-6700 until Sprint releases the &lt;A href="http://www.htc.com/www/product.aspx?id=46278" target=_blank mce_href="http://www.htc.com/www/product.aspx?id=46278"&gt;HTC Touch Diamond&lt;/A&gt; (or Pro) later this year.&amp;nbsp; &lt;/P&gt;
&lt;P&gt;Although I’ll admit that I have to reboot my Windows mobile phone every other day or so, it was really hard giving up all of the flexibility.&amp;nbsp; The Instinct had a great touch screen, many excellent features (especially the GPS capabilities and visual voice mail), but the lack of EVDO Rev A speed (even though it’s supposedly built-in…although I never got it) and poor browser just weren’t worth it.&amp;nbsp; My browsing experience is much faster on my EVDO enabled PPC-6700 even though it’s 2 years old.&amp;nbsp; &lt;/P&gt;
&lt;P&gt;Last night I installed a Midlet Manager on my PPC-6700 and have Opera 4.1 mini going and it’s amazing how much faster it is than what I was getting on the Instinct.&amp;nbsp; I also installed the latest version of &lt;A href="http://spbsoftwarehouse.com/?en" target=_blank mce_href="http://spbsoftwarehouse.com/?en"&gt;SPB Software’s&lt;/A&gt; Mobile Shell and Pocket Plus which have some nice UI enhancements built-in.&amp;nbsp; I doubt I’ll be switching from a Windows Mobile phone in the future unless something really, really cool gets released.&amp;nbsp; Once you’ve been accustomed to all of the power available on Windows Mobile it’s really hard to leave it.&amp;nbsp; I’m kind of bummed that the Instinct didn’t work out for me since I tried really hard to work with it.&amp;nbsp; I’m hoping the HTC Diamond ends up being as cool as it looks.&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Need to display OrgCharts, site maps or other hierarchies in your ASP.NET applications?&amp;nbsp; Check out &lt;A href="http://www.smartwebcontrols.com/" target=_blank&gt;SmartChartPro&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;&lt;A href="http://www.smartwebcontrols.com/" target=_blank&gt;&lt;IMG src="http://www.smartwebcontrols.com/images/smartchartprologo.gif" border=0&gt;&lt;/A&gt;&lt;/P&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6407197" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/dwahlin/archive/tags/.NET/default.aspx">.NET</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/Mobile/default.aspx">Mobile</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/Phone/default.aspx">Phone</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/Instinct/default.aspx">Instinct</category></item><item><title>Sprint Instinct Tips and Tricks</title><link>http://weblogs.asp.net/dwahlin/archive/2008/07/10/sprint-instinct-tips-and-tricks.aspx</link><pubDate>Thu, 10 Jul 2008 07:27:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6382895</guid><dc:creator>dwahlin</dc:creator><slash:comments>10</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/dwahlin/rsscomments.aspx?PostID=6382895</wfw:commentRss><comments>http://weblogs.asp.net/dwahlin/archive/2008/07/10/sprint-instinct-tips-and-tricks.aspx#comments</comments><description>&lt;P&gt;&lt;IMG src="http://weblogs.asp.net/blogs/dwahlin/WindowsLiveWriter/SprintInstinctProsandCons_9D36/samsung_sprint_instinct_thumb_1.jpg" align=right mce_src="http://weblogs.asp.net/blogs/dwahlin/WindowsLiveWriter/SprintInstinctProsandCons_9D36/samsung_sprint_instinct_thumb_1.jpg"&gt; In a &lt;A href="http://weblogs.asp.net/dwahlin/archive/2008/06/26/pros-and-cons-of-the-sprint-instinct-phone.aspx" target=_blank mce_href="http://weblogs.asp.net/dwahlin/archive/2008/06/26/pros-and-cons-of-the-sprint-instinct-phone.aspx"&gt;previous post&lt;/A&gt; I discussed some of the pros and cons of the new Sprint Instinct phone that I recently purchased.&amp;nbsp; I’ve had the phone for a few weeks now and still like it a lot overall.&amp;nbsp; It’s not nearly as flexible as the PPC-6700 phone I had previously when it comes to installing software (a lot of applications like Opera Mini won’t work due to a virtual keyboard issue that Sprint/Samsumg will hopefully fix), but it shines in many areas where my Windows Mobile phone was severely lacking such as visual voice mail, GPS navigation, flexible touch screen interface, business search (with GPS positioning), plus more.&lt;/P&gt;
&lt;P&gt;Now that I’ve had the phone and tried out about every feature I could find I thought I’d put together a tips and tricks section for others who may have the phone.&amp;nbsp; Most of these tips and tricks I found through experimentation (I like to tinker with devices) while others I discovered using Google and Live.com.&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;STRONG&gt;Scrolling in the Browser &lt;/STRONG&gt;– When you’re using the Instinct’s browser you can click the camera button and move the device to scroll left to right or top to bottom.&amp;nbsp; It’s kind of a gimmick feature in my opinion since it doesn’t seem to work consistently, but it’s nice to know about.&amp;nbsp; The second icon down on the left of the browser can also be used to quickly move to different parts of&amp;nbsp; page.&amp;nbsp; A lot of people complain about the browser but it’s useable for most sites.&amp;nbsp; I really hope that Opera Mini 4.1 makes it onto the Instinct though.&lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;Using Opera Mini&lt;/STRONG&gt; – &lt;A href="http://www.operamini.com/" target=_blank mce_href="http://www.operamini.com"&gt;Opera Mini 4.1&lt;/A&gt; (one of the coolest mobile browsers out there) doesn’t currently work on the Instinct unfortunately (as of 7/9/2008)…...bummer.&amp;nbsp; It loads the first time but no keyboard pops-up when user input is required and it doesn’t generally load more than once without uninstalling and reinstalling it.&amp;nbsp; The lack of support for keyboard input in the Instinct for existing Java applications is a problem although &lt;A href="http://sprintusers.com/forum/showthread.php?t=167813" target=_blank mce_href="http://sprintusers.com/forum/showthread.php?t=167813"&gt;rumor has it&lt;/A&gt; that Sprint/Samsung will release a fix for the problem in the future.&amp;nbsp; Although Opera Mini 4.1 doesn’t work, Opera Mini 3.0 does work and is useful when you want to view sites.&amp;nbsp; User input isn’t supported unfortunately, but you can drill down into sites and feeds provided by the browser to get to most major sites out there and then do some tricks to post your own custom bookmarks online.&amp;nbsp; More details can be found &lt;A href="http://www.sprintinstinctforum.com/forum/viewtopic.php?f=36&amp;amp;t=654" target=_blank mce_href="http://www.sprintinstinctforum.com/forum/viewtopic.php?f=36&amp;amp;t=654"&gt;here&lt;/A&gt; and &lt;A href="http://instinctbookmarks.blogspot.com/2008/06/exclusive-how-to-use-opera-mini-3-older.html" target=_blank mce_href="http://instinctbookmarks.blogspot.com/2008/06/exclusive-how-to-use-opera-mini-3-older.html"&gt;here&lt;/A&gt;.&lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;Setting a Custom Desktop Wallpaper&lt;/STRONG&gt; – When the power button for the phone is clicked a default screen comes up that explains how to unlock the phone.&amp;nbsp; You can assign a custom background (such as a picture you took with the phone) to this screen by going to Main &amp;gt; Settings &amp;gt; Display &amp;gt; Background and select the picture you’d like.&amp;nbsp; You can access custom images as well quite easily by uploading them to &lt;A href="http://www.myxer.com/" target=_blank mce_href="http://www.myxer.com"&gt;Myxer.com&lt;/A&gt;.&lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;Assigning a Custom Ring Tone – &lt;/STRONG&gt;I mentioned this in my previous Instinct post but it’s a nice trick to know.&amp;nbsp; An easy way to add a custom ring tone is to go to &lt;A href="http://www.myxer.com/" mce_href="http://www.myxer.com/"&gt;http://www.myxer.com&lt;/A&gt; and upload a music file, adjust which parts you want to be your ring tone and then download the file on your phone.&amp;nbsp; Read more about making custom ring tones for the Instinct &lt;A href="http://www.instinct-samsung.com/index.php/topic,407.0.html" mce_href="http://www.instinct-samsung.com/index.php/topic,407.0.html"&gt;here&lt;/A&gt;.&lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;Fast Text Messages or Emails – &lt;/STRONG&gt;The Instinct has handwriting recognition support built-in that even works well with my messy handwriting.&amp;nbsp; When you’re composing an email or text message click the pencil icon to get to the handwriting recognition feature.&amp;nbsp; It supports writing complete words rather than drawing one character at a time which is nice.&amp;nbsp; I haven’t successfully used the feature with my finger, but it works well with the included stylus.&lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;Quickly View Emails. Text Messages or Pictures – &lt;/STRONG&gt;Because the Instinct is a touch phone you can move your finger from left to right (or right to left) to move through pictures you may have on the SD card.&amp;nbsp; You can use this same technique to quickly flip through emails.&amp;nbsp; View an email that you’d like to read and swipe your finger from right to left on the screen to see the next email.&amp;nbsp; You can do this with text messages as well.&lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;Deleting or Reordering Text Messages&lt;/STRONG&gt; – Text messages can be deleted by highlighting them and clicking the trash icon or by holding them for a moment (until the target message changes colors) and then dragging them to the trash icon.&amp;nbsp; The Instinct threads text messages and you can move messages around to change their order by using this same technique (although you wouldn’t move them to the trash icon of course!).&lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;Sending Voice Memos– &lt;/STRONG&gt;This is one of my favorite tips for the Instinct since I like to record &lt;A href="http://weblogs.asp.net/dwahlin/archive/tags/Music/default.aspx" target=_blank mce_href="http://weblogs.asp.net/dwahlin/archive/tags/Music/default.aspx"&gt;song ideas&lt;/A&gt; that I get from time to time so that I don’t forget them.&amp;nbsp; I’ll admit that I didn’t figure this one out on my own but read about it &lt;A href="http://www.sprintusers.com/forum/showthread.php?t=166683&amp;amp;page=7" target=_blank mce_href="http://www.sprintusers.com/forum/showthread.php?t=166683&amp;amp;page=7"&gt;here&lt;/A&gt;.&amp;nbsp; You can send yourself a voice memo quickly and easily.&amp;nbsp; To start, add yourself as a contact in the phone.&amp;nbsp; I added my name, phone number and email address.&amp;nbsp; Once your contact information is setup, click on the VoiceMail icon on the Main screen and click the + icon in the left corner.&amp;nbsp; Select yourself (or another contact) from the contact list and then record your message.&amp;nbsp; Once the message is recorded click the Send button.&amp;nbsp; This sends a Windows Media file (.wma extension) to your email address if that’s what you selected or a voice mail to yourself if you selected your phone number.&amp;nbsp; You can use this to send voice recordings to other contacts as well and they can open the wma email attachment on Windows to hear it.&amp;nbsp; If you send it to a contact’s phone number they’ll receive a text message with a phone number they can call to retrieve the message.&amp;nbsp; On a related note, there’s a free service out there called &lt;A href="http://jott.com/" target=_blank mce_href="http://jott.com/"&gt;Jott&lt;/A&gt; that converts voice messages into text/emails.&amp;nbsp; Nothing specific to the Instinct but kind of cool when you don’t want to forget something and would like to get an email about it later.&lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;Streaming Custom TV and Audio – &lt;/STRONG&gt;The Instinct has built-in support for TV and radio stations but sometimes it’s nice to get to your own music files or TV stations.&amp;nbsp; I mentioned this in the earlier post, but the Instinct works great with &lt;A href="http://www.orb.com/" target=_blank mce_href="http://www.orb.com"&gt;orb.com&lt;/A&gt;.&amp;nbsp; If you haven’t heard of Orb, it’s a free software program you install on your home computer to allow your phone (and other computers and devices) to access your computer’s audio files and even TV stations (if TV is enabled on the PC).&amp;nbsp; Check out &lt;A href="http://www.orb.com/" target=_blank mce_href="http://www.orb.com"&gt;Orb.com&lt;/A&gt; for more details.&amp;nbsp; Once you have Orb setup on your home PC, navigate to the Orb.com site on your phone, login and go to the Settings page.&amp;nbsp; Change the Stream format to 3GP Format (.sdp) to get audio and TV streaming properly on your Instinct phone.&lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;Upload Photos to PhotoBucket&lt;/STRONG&gt; – The Instinct’s camera works pretty well when there’s good lighting available and sooner or later you’ll want to upload pictures you take.&amp;nbsp; To upload pictures easily go to the Fun tab (on the home screen) and click the Tap to Add icon located in the bottom right-hand corner.&amp;nbsp; You’ll see a few entries including PhotoBucket (a site similar to Flickr).&amp;nbsp; Click it to add the PhotoBucket upload service to your Fun screen.&amp;nbsp; Go to your PC and create a PhotoBucket account by browsing to &lt;A href="http://www.photobucket.com/" mce_href="http://www.photobucket.com"&gt;http://www.photobucket.com&lt;/A&gt; and then click the PhotoBucket icon on the Fun tab, supply your login information and start uploading pictures.&amp;nbsp; You can also upload pictures to Facebook or Sprint’s photo service.&lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;Finding Directions with GPS&lt;/STRONG&gt; – This tip is more obvious, but if you haven’t seen it before it’s definitely useful.&amp;nbsp; When you go to the Instinct’s Navigation screen you can click on &lt;EM&gt;Drive To&lt;/EM&gt; followed by &lt;EM&gt;Address&lt;/EM&gt; to enter the destination address.&amp;nbsp; What if you don’t know the address though?&amp;nbsp; On the bottom of the screen you’ll see &lt;EM&gt;Intersection&lt;/EM&gt; and &lt;EM&gt;City&lt;/EM&gt; tabs which are useful when you simply need to get to a specific area rather than a specific address.&lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;Changing the Size of Email Messages&lt;/STRONG&gt; – You can change the amount of text shown in email messages by going to Main &amp;gt; Email and navigating to the Email Homepage.&amp;nbsp; Once there (and this assumes you already have an email account setup), click the Message/Gears icon to the right of the the desired email account to get to the email settings.&amp;nbsp; Click the Settings button at the bottom of the screen and then choose how much text you want to download.&amp;nbsp; I set mine to 3K of text.&amp;nbsp; I got annoyed by the ring tone that was played each time an email arrived so I also set the &lt;EM&gt;Tell me I have mail&lt;/EM&gt; setting to &lt;EM&gt;Off&lt;/EM&gt;.&lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;Turning Off the Ringer&lt;/STRONG&gt; – It’s surprising how bad phone etiquette can be in business meetings, movies, etc.&amp;nbsp; I always try to remember (although I’ll admit I forget sometimes) to turn off my phone’s ringer where appropriate to avoid interrupting people since it’s the courteous thing to do.&amp;nbsp; You can go to Main &amp;gt; Settings &amp;gt; Volume &amp;amp; Vibration to turn down your ringer volume or go to Main &amp;gt; Settings &amp;gt; General to turn on airplane mode (which disables voice and data communications entirely).&amp;nbsp; However, the easiest way to do this is to click the down volume button (left side of the phone) several times.&amp;nbsp; As you do it you’ll see that you can switch to vibrate mode, no ringer, etc.&amp;nbsp; Click the up volume button several times to return the ringer back to normal.&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;That’s it for now.&amp;nbsp; There are a lot more tips and tricks I’ve come across while using the phone which I’ll try to post in the future. If you’re an Instinct owner and have some tips/tricks you’d like to share please add a comment below.&lt;/P&gt;
&lt;P&gt;Need to display OrgCharts, site maps or other hierarchies in your ASP.NET applications?&amp;nbsp; Check out &lt;A href="http://www.smartwebcontrols.com/" mce_href="http://www.smartwebcontrols.com"&gt;SmartChartPro&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;&lt;A href="http://www.smartwebcontrols.com/" mce_href="http://www.smartwebcontrols.com"&gt;&lt;IMG src="http://www.smartwebcontrols.com/images/smartchartprologo.gif" border=0 mce_src="http://www.smartwebcontrols.com/images/smartchartprologo.gif"&gt;&lt;/A&gt;&lt;/P&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6382895" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/dwahlin/archive/tags/.NET/default.aspx">.NET</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/Phone/default.aspx">Phone</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/Java/default.aspx">Java</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/Instinct/default.aspx">Instinct</category></item><item><title>Pros and Cons of the Sprint Instinct Phone</title><link>http://weblogs.asp.net/dwahlin/archive/2008/06/26/pros-and-cons-of-the-sprint-instinct-phone.aspx</link><pubDate>Thu, 26 Jun 2008 20:03:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6324160</guid><dc:creator>dwahlin</dc:creator><slash:comments>37</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/dwahlin/rsscomments.aspx?PostID=6324160</wfw:commentRss><comments>http://weblogs.asp.net/dwahlin/archive/2008/06/26/pros-and-cons-of-the-sprint-instinct-phone.aspx#comments</comments><description>&lt;P mce_keep="true"&gt;There’s been a lot of hype over Apple’s new &lt;A href="http://www.apple.com/iphone/" target=_blank mce_href="http://www.apple.com/iphone/"&gt;iPhone 3G&lt;/A&gt; coming out on July 11th as well as Sprint’s recently released &lt;A href="http://www.instinctthephone.com/?id12=UHP_Masthead_062008_instinctthephone" target=_blank mce_href="http://www.instinctthephone.com/?id12=UHP_Masthead_062008_instinctthephone"&gt;Instinct&lt;/A&gt; phone.&amp;nbsp; I was originally going to switch over to AT&amp;amp;T and get the iPhone but it meant switching my wife &lt;A href="http://weblogs.asp.net/blogs/dwahlin/WindowsLiveWriter/SprintInstinctProsandCons_9D36/samsung_sprint_instinct_4.jpg" mce_href="http://weblogs.asp.net/blogs/dwahlin/WindowsLiveWriter/SprintInstinctProsandCons_9D36/samsung_sprint_instinct_4.jpg"&gt;&lt;IMG title=samsung_sprint_instinct style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height=346 alt=samsung_sprint_instinct src="http://weblogs.asp.net/blogs/dwahlin/WindowsLiveWriter/SprintInstinctProsandCons_9D36/samsung_sprint_instinct_thumb_1.jpg" width=267 align=right border=0 mce_src="http://weblogs.asp.net/blogs/dwahlin/WindowsLiveWriter/SprintInstinctProsandCons_9D36/samsung_sprint_instinct_thumb_1.jpg"&gt;&lt;/A&gt; over as well since we need to be able to call each other without using plan minutes.&amp;nbsp; After evaluating the cost of switching carriers we decided it wasn’t worth it since we’d have to pay $400 to get out of our Sprint contracts and my wife recently bought the PPC-6800 Windows Mobile phone which wasn’t cheap.&amp;nbsp; We’ve been very happy with Sprint’s network in our area as well.&lt;/P&gt;
&lt;P&gt;&lt;A href="http://weblogs.asp.net/blogs/dwahlin/WindowsLiveWriter/SprintInstinctProsandCons_9D36/sprint-instinct_2.jpg" mce_href="http://weblogs.asp.net/blogs/dwahlin/WindowsLiveWriter/SprintInstinctProsandCons_9D36/sprint-instinct_2.jpg"&gt;&lt;IMG title=sprint-instinct style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height=180 alt=sprint-instinct src="http://weblogs.asp.net/blogs/dwahlin/WindowsLiveWriter/SprintInstinctProsandCons_9D36/sprint-instinct_thumb.jpg" width=240 align=left border=0 mce_src="http://weblogs.asp.net/blogs/dwahlin/WindowsLiveWriter/SprintInstinctProsandCons_9D36/sprint-instinct_thumb.jpg"&gt;&lt;/A&gt;Before getting the Instinct I had a PPC-6700 so I had to choose between going away from a Windows Mobile phone to a totally different type of touch screen phone that wasn’t based on Windows.&amp;nbsp; With a Windows Mobile phone you have full control over just about anything you want which is nice if you’re a power user.&amp;nbsp; But, the flexibility does come at a price.&amp;nbsp; I also had the problem of not being able to answer calls on occasion, having to reboot almost daily, poor battery life, plus a few others.&amp;nbsp; Truth be told, I really liked my Windows Mobile phone overall and would buy another one. But, after thinking things through more I came to the conclusion that I mainly used my PPC-6700 for calls, text messaging and the Web and that all of the other bells and whistles were rarely used.&amp;nbsp; I decided to give the Instinct a try since I really liked the touch screen when I tried out the demo version at the Sprint store and liked some of the features it had such as built-in GPS and streaming TV/radio support.&lt;/P&gt;
&lt;P&gt;Here’s what I really like about the Sprint Instinct:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;STRONG&gt;Visual Voice Mail&lt;/STRONG&gt; – I’ve always hated skipping through message after message to get to the one I wanted to listen to.&amp;nbsp; Visual voice mail lets me see my messages just like emails, rewind and fast-forward messages just by sliding my finger on the screen, and deleting messages that I know I don’t need to listen to quickly and easily.&lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;GPS Navigation –&lt;/STRONG&gt; The Instinct has great GPS navigation capabilities.&amp;nbsp; 2-D and 3-D views are available, voice navigation (which includes announcing street names), directions, etc.&lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;Nice Form Factor&lt;/STRONG&gt; – The Instinct fits into my hands much better than the PPC-6700 I had before and is really light…yet feels solid.&amp;nbsp; I suspect those with a Motorola Q or similar models won’t notice that much of a difference, but coming from a “brick” it’s really nice.&lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;Great Touch Screen&lt;/STRONG&gt; – The touch screen on the Instinct is really, really nice.&amp;nbsp; It’s much better than I was expecting and provides “haptic” feedback.&amp;nbsp; Basically you get a little vibration each time you click something successfully on the screen.&amp;nbsp; Very nice!&lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;Fast Download Speeds&lt;/STRONG&gt; – From what I’ve heard, Sprint’s EV-DO Rev A network hasn’t officially been turned on yet (last I heard that would happen in July sometime) but the download speeds have been really good.&amp;nbsp; Good enough that I can stream music or TV from home using &lt;A href="http://www.orb.com/" target=_blank mce_href="http://www.orb.com"&gt;Orb&lt;/A&gt; quite easily (if you’re going to use Orb with Instinct &lt;A href="http://www.instinct-samsung.com/index.php/topic,680.0.html" target=_blank mce_href="http://www.instinct-samsung.com/index.php/topic,680.0.html"&gt;check out this post&lt;/A&gt;).&amp;nbsp; &lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;POP/IMAP Email&lt;/STRONG&gt;&amp;nbsp;&lt;STRONG&gt;Access&lt;/STRONG&gt; – Some of the early reviews I saw said that you could only integrate with Web-based email accounts like Hotmail or GMail.&amp;nbsp; That’s not true at all.&amp;nbsp; I’m able to successfully access POP or IMAP email accounts easily and get nice notifications when an email arrives.&lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;Speech to Action &lt;/STRONG&gt;– Need to find a gas station or restaurant that’s close to where you are?&amp;nbsp; Want to call or text someone? The Instinct has integrated “speech to action” features that integrate with Live Search, the phone, text messaging, etc.&amp;nbsp; Say the business name you want and instantly get access to directions, maps, etc. (assuming it can find the place of course).&amp;nbsp; The voice recognition doesn’t require training and has worked well for me so far.&amp;nbsp; It can be trained for additional accuracy too through the settings dialog.&lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;Traffic&lt;/STRONG&gt; – I carpool to downtown Phoenix now so I’m not as worried about traffic as I used to be, but the Instinct’s GPS features also allow traffic information to be viewed including accidents, average freeway speeds, etc.&amp;nbsp; Haven’t used that feature a ton but did try it out twice and it seemed fairly accurate.&lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;Fast Access to News/Sports/Weather&lt;/STRONG&gt; – The Instinct provides nice news and weather viewers to get information about all kinds of things.&amp;nbsp; Radar maps are also available for the weather.&lt;A href="http://weblogs.asp.net/blogs/dwahlin/WindowsLiveWriter/SprintInstinctProsandCons_9D36/samsung-instinct0_2.jpg" mce_href="http://weblogs.asp.net/blogs/dwahlin/WindowsLiveWriter/SprintInstinctProsandCons_9D36/samsung-instinct0_2.jpg"&gt;&lt;IMG title=samsung-instinct0 style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height=362 alt=samsung-instinct0 src="http://weblogs.asp.net/blogs/dwahlin/WindowsLiveWriter/SprintInstinctProsandCons_9D36/samsung-instinct0_thumb.jpg" width=190 align=right border=0 mce_src="http://weblogs.asp.net/blogs/dwahlin/WindowsLiveWriter/SprintInstinctProsandCons_9D36/samsung-instinct0_thumb.jpg"&gt;&lt;/A&gt; &lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;Solid Bluetooth Support&lt;/STRONG&gt; – My PPC-6700 had Bluetooth support but I had to turn it off and on each time I got in my truck so that it would properly sync.&amp;nbsp; The Instinct’s Bluetooth support is much, much better.&amp;nbsp; It syncs perfectly every time with my system and can also be used with stereo Bluetooth headphones (which I don’t have…so I don’t know how well that feature works).&lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;TV/Radio&lt;/STRONG&gt; -&amp;nbsp; I don’t watch TV much, but the Instinct makes it easy to watch a wide variety of TV shows on the device and provides many radio stations as well.&amp;nbsp; The quality of the streamed music has been great even while driving.&amp;nbsp; I listened to a station while driving for about 30 minutes last night with only a few hiccups.&amp;nbsp; As mentioned earlier, I use &lt;A href="http://www.orb.com/" target=_blank mce_href="http://www.orb.com"&gt;Orb&lt;/A&gt; to stream TV or music from my home PC to my Instinct as well…I highly recommend Orb.&amp;nbsp; All of this should get even better once the EV-DO Rev A network hits the airwaves.&lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;Java Based&lt;/STRONG&gt; – Because the Instinct uses Java behind the scenes a lot of &lt;A href="http://www.instinct-samsung.com/index.php?action=search2" target=_blank mce_href="http://www.instinct-samsung.com/index.php?action=search2"&gt;custom apps and games&lt;/A&gt; can be run on it.&amp;nbsp; There are precious few applications out there right now for the Instinct (although I have found some games that work fine).&amp;nbsp; Sprint is running a &lt;A href="http://developer.sprint.com/instinct/" target=_blank mce_href="http://developer.sprint.com/instinct/"&gt;developer contest&lt;/A&gt; so I suspect we’ll see a flood of apps coming out soon.&amp;nbsp; I’m a &lt;A href="http://msdn.microsoft.com/" target=_blank mce_href="http://msdn.microsoft.com"&gt;Microsoft .NET developer&lt;/A&gt; but since there are a ton of mobile Java applications out there I’m guessing many will be ported to the Instinct.&amp;nbsp; Time to brush up on my Java some.&lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;SD Card&lt;/STRONG&gt; – Music and other items can be stored on an SD card (up to 8gig).&lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;Battery Life&lt;/STRONG&gt; – For people that don’t have Windows Mobile phones this probably won’t be a big deal.&amp;nbsp; My PPC-6700 had horrible battery life though so it’s nice to have a phone that lasts a long time even when watching TV or streaming music.&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;Here’s what I don’t love about the phone:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;STRONG&gt;Internet Browser&lt;/STRONG&gt; – The Internet browser built-into the Instinct works fine for many sites and provides a way to zoom in and out and easily scroll down to different parts of a site.&amp;nbsp; However, it’s nothing compared to the &lt;A href="http://www.operamini.com/" target=_blank mce_href="http://www.operamini.com/"&gt;Opera Mini&lt;/A&gt; browser.&amp;nbsp; Unfortunately, the Opera Mini browser doesn’t currently work on the Instinct.&amp;nbsp; I suspect it will in the future given all of the interest in the device but we’ll have to wait and see.&amp;nbsp; The built-in browser can only be viewed in landscape mode which is annoying at times as well.&lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;Load Issue (minor issue)&lt;/STRONG&gt; – The phone normally boots up really fast when I turn it all the way off.&amp;nbsp; However, there have been 2 times where the load screen sat there for 5+ minutes.&amp;nbsp; After some time it loads fine, but it’s annoying when it has the temporary hang.&lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;Ring tones&lt;/STRONG&gt; – I always use custom MP3 ring tones and although the Instinct includes some nice ones, there’s no &lt;EM&gt;built-in way&lt;/EM&gt; to add your own custom ring tones.&amp;nbsp; However, you can go to &lt;A href="http://www.myxer.com/" mce_href="http://www.myxer.com"&gt;http://www.myxer.com&lt;/A&gt; and take care of that quite easily.&amp;nbsp; Myxer provides a simple way to upload a music file (or wallpaper), adjust which parts you want to be your ring tone and then download it on your phone.&amp;nbsp; Read more about making custom ring tones &lt;A href="http://www.instinct-samsung.com/index.php/topic,407.0.html" target=_blank mce_href="http://www.instinct-samsung.com/index.php/topic,407.0.html"&gt;here&lt;/A&gt;.&lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;No Voice Recording&lt;/STRONG&gt; – I like to &lt;A href="http://weblogs.asp.net/dwahlin/archive/2008/04/27/silverlight-the-song.aspx" target=_blank mce_href="http://weblogs.asp.net/dwahlin/archive/2008/04/27/silverlight-the-song.aspx"&gt;write and record music&lt;/A&gt; in my spare time and frequently used a program on my PPC-6700 to record song ideas I had so that I didn’t forget them.&amp;nbsp; I haven’t found a way to do voice recording on the Instinct yet although it certainly has the technology in place.&amp;nbsp; Time to write an application that can do that I guess.&lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;TV/Radio Doesn’t Stream Sometimes&lt;/STRONG&gt; – I mentioned earlier that I really like the TV and radio support built-into the Instinct.&amp;nbsp; On a few occasions I would try to watch a TV show or stream a radio station and get nothing.&amp;nbsp; I suspect it was a network issue at the time or something along those lines.&amp;nbsp; The TV/radio features seem to work great overall though.&lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;No Themes/Skins&lt;/STRONG&gt; – The Instinct only comes with 1 theme which can’t be changed at this point.&amp;nbsp; I’m surprised they didn’t offer several themes/skins.&amp;nbsp; If someone wants a more iPhone looking interface then that should certainly be possible (I do like the overall interface of the iPhone much better….seems cleaner).&amp;nbsp; I’m hoping that Sprint or a 3rd party company will release different themes that can be used on the phone.&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;&lt;A href="http://weblogs.asp.net/blogs/dwahlin/WindowsLiveWriter/SprintInstinctProsandCons_9D36/Sprint_1_2.jpg" mce_href="http://weblogs.asp.net/blogs/dwahlin/WindowsLiveWriter/SprintInstinctProsandCons_9D36/Sprint_1_2.jpg"&gt;&lt;IMG title=Sprint_1 style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height=144 alt=Sprint_1 src="http://weblogs.asp.net/blogs/dwahlin/WindowsLiveWriter/SprintInstinctProsandCons_9D36/Sprint_1_thumb.jpg" width=240 align=left border=0 mce_src="http://weblogs.asp.net/blogs/dwahlin/WindowsLiveWriter/SprintInstinctProsandCons_9D36/Sprint_1_thumb.jpg"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;I have 30 days to try out the Instinct and if I don’t end up liking it I’ll turn it in for a PPC-6800.&amp;nbsp; However, at this point I’m really happy with it and although there are a few annoyances (what product doesn’t have them though?) I’m planning on keeping it at this point.&amp;nbsp; For a first version device they did an amazing job and I think Sprint has a winner on their hands.&amp;nbsp; It’s no iPhone killer in my opinion having played with some friends’ iPhones in the past, but once they make a better browser available it’ll definitely blur the lines between the two devices.&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;IMG title=Twitter height=60 alt=Twitter src="http://weblogs.asp.net/blogs/dwahlin/WindowsLiveWriter/PushingDatatoaSilverlightClientwithaWCFD_89D4/Twitter_5.jpg" width=219 align=left border=0 mce_src="http://weblogs.asp.net/blogs/dwahlin/WindowsLiveWriter/PushingDatatoaSilverlightClientwithaWCFD_89D4/Twitter_5.jpg"&gt;&amp;nbsp; Already on Twitter and interested in getting live updates about blog posts and other information?&amp;nbsp; Subscribe to my Twitter feed at &lt;A href="http://www.twitter.com/DanWahlin" mce_href="http://www.twitter.com/DanWahlin"&gt;http://www.twitter.com/DanWahlin&lt;/A&gt;.&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Need to display OrgCharts, site maps or other hierarchies in your ASP.NET applications?&amp;nbsp; Check out &lt;A href="http://www.smartwebcontrols.com/" target=_blank&gt;SmartChartPro&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;&lt;A href="http://www.smartwebcontrols.com/" target=_blank&gt;&lt;IMG src="http://www.smartwebcontrols.com/images/smartchartprologo.gif" border=0&gt;&lt;/A&gt;&lt;/P&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6324160" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/dwahlin/archive/tags/.NET/default.aspx">.NET</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/Phone/default.aspx">Phone</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/Java/default.aspx">Java</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/Instinct/default.aspx">Instinct</category></item><item><title>Pushing Data to a Silverlight Client with a WCF Duplex Service – Part II</title><link>http://weblogs.asp.net/dwahlin/archive/2008/06/19/pushing-data-to-a-silverlight-client-with-a-wcf-duplex-service-part-ii.aspx</link><pubDate>Thu, 19 Jun 2008 21:34:21 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6297362</guid><dc:creator>dwahlin</dc:creator><slash:comments>13</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/dwahlin/rsscomments.aspx?PostID=6297362</wfw:commentRss><comments>http://weblogs.asp.net/dwahlin/archive/2008/06/19/pushing-data-to-a-silverlight-client-with-a-wcf-duplex-service-part-ii.aspx#comments</comments><description>&lt;p&gt;&lt;/p&gt;  &lt;p&gt;In &lt;a href="http://weblogs.asp.net/dwahlin/archive/2008/06/16/pushing-data-to-a-silverlight-client-with-wcf-duplex-service-part-i.aspx" target="_blank"&gt;Part 1&lt;/a&gt; of this series on pushing data to a Silverlight client with a WCF polling duplex service I demonstrated how service contracts and operations can be defined on the server.&amp;#160; WCF has built-in support for duplex communication (two-way communication between a service and a client) but does require a reference to System.ServiceModel.PollingDuplex.dll to make it work with Silverlight.&amp;#160; This assembly is provided in the Silverlight SDK and is currently in “evaluation” mode (the Silverlight go-live license doesn’t apply to it).&amp;#160; With the polling duplex model the Silverlight client does poll the service to check if any messages are queued so it’s not as “pure” as the sockets option available in Silverlight when it comes to pushing data from a server to a client.&amp;#160; However, it offers much greater flexibility when compared to sockets since it isn’t limited to a specific port range and works over HTTP.&amp;#160; &lt;/p&gt;  &lt;p&gt;Let’s take a look at how a Silverlight client can send and receive messages from a polling duplex WCF service and what types of messages are sent between the two.&lt;/p&gt;  &lt;h2&gt;Understanding Polling Duplex Messages&lt;/h2&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;A polling duplex service communicates with a Silverlight client using WCF &lt;a href="http://msdn.microsoft.com/en-us/library/system.servicemodel.channels.message.aspx" target="_blank"&gt;Message&lt;/a&gt; types.&amp;#160; This provides complete control over the data sent between the client and the service and allows communication between the two to be loosely coupled.&amp;#160; The downside of this is that messages must be manually serialized/deserialized by the client and service since the WSDL type information uses the &lt;strong&gt;xs:any&lt;/strong&gt; element.&amp;#160; Here’s what the service’s WSDL types section looks like (notice the inclusion of the xs:any element) when a service uses the Message type as a parameter for an operation:&lt;/p&gt;  &lt;pre class="code"&gt;&lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;xs:schema &lt;/span&gt;&lt;span style="color: red"&gt;elementFormDefault&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color: blue"&gt;qualified&lt;/span&gt;&amp;quot; &lt;span style="color: red"&gt;targetNamespace&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color: blue"&gt;http://schemas.microsoft.com/Message&lt;/span&gt;&amp;quot; &lt;span style="color: red"&gt;xmlns:xs&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color: blue"&gt;http://www.w3.org/2001/XMLSchema&lt;/span&gt;&amp;quot; 
  &lt;span style="color: red"&gt;xmlns:tns&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color: blue"&gt;http://schemas.microsoft.com/Message&lt;/span&gt;&amp;quot;&lt;span style="color: blue"&gt;&amp;gt;
&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;xs:complexType &lt;/span&gt;&lt;span style="color: red"&gt;name&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color: blue"&gt;MessageBody&lt;/span&gt;&amp;quot;&lt;span style="color: blue"&gt;&amp;gt;
  &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;xs:sequence&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
    &lt;strong&gt;&amp;lt;&lt;/strong&gt;&lt;/span&gt;&lt;strong&gt;&lt;span style="color: #a31515"&gt;xs:any &lt;/span&gt;&lt;span style="color: red"&gt;minOccurs&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color: blue"&gt;0&lt;/span&gt;&amp;quot; &lt;span style="color: red"&gt;maxOccurs&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color: blue"&gt;unbounded&lt;/span&gt;&amp;quot; &lt;span style="color: red"&gt;namespace&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color: blue"&gt;##any&lt;/span&gt;&amp;quot;&lt;/strong&gt;&lt;span style="color: blue"&gt;&lt;strong&gt;/&amp;gt;&lt;/strong&gt;
  &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;xs:sequence&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;xs:complexType&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;xs:schema&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;An example of using the WCF Message type in a WCF service is shown next.&amp;#160; Details about this code were covered in &lt;a href="http://weblogs.asp.net/dwahlin/archive/2008/06/16/pushing-data-to-a-silverlight-client-with-wcf-duplex-service-part-i.aspx" target="_blank"&gt;Part I&lt;/a&gt; of this series.&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;using &lt;/span&gt;System;
&lt;span style="color: blue"&gt;using &lt;/span&gt;System.ServiceModel;
&lt;span style="color: blue"&gt;using &lt;/span&gt;System.ServiceModel.Channels;
&lt;span style="color: blue"&gt;using &lt;/span&gt;System.Threading;

&lt;span style="color: blue"&gt;namespace &lt;/span&gt;WCFPushService
{
    &lt;span style="color: blue"&gt;public class &lt;/span&gt;&lt;span style="color: #2b91af"&gt;GameStreamService &lt;/span&gt;: &lt;span style="color: #2b91af"&gt;IGameStreamService
    &lt;/span&gt;{
        &lt;span style="color: #2b91af"&gt;IGameStreamClient &lt;/span&gt;_Client;
        &lt;span style="color: #2b91af"&gt;Game &lt;/span&gt;_Game = &lt;span style="color: blue"&gt;null&lt;/span&gt;;
        &lt;span style="color: #2b91af"&gt;Timer &lt;/span&gt;_Timer = &lt;span style="color: blue"&gt;null&lt;/span&gt;;
        &lt;span style="color: #2b91af"&gt;Random &lt;/span&gt;_Random = &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;Random&lt;/span&gt;();

        &lt;span style="color: blue"&gt;public &lt;/span&gt;GameStreamService()
        {
            _Game = &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;Game&lt;/span&gt;();
        }

        &lt;span style="color: blue"&gt;public void &lt;/span&gt;GetGameData(&lt;span style="color: #2b91af"&gt;Message &lt;/span&gt;receivedMessage)
        {

            &lt;span style="color: green"&gt;//Get client callback channel
            &lt;/span&gt;_Client = &lt;span style="color: #2b91af"&gt;OperationContext&lt;/span&gt;.Current.GetCallbackChannel&amp;lt;&lt;span style="color: #2b91af"&gt;IGameStreamClient&lt;/span&gt;&amp;gt;();

            SendData(_Game.GetTeamData());
            &lt;span style="color: green"&gt;//Start timer which when fired sends updated score information to client
            &lt;/span&gt;_Timer = &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;Timer&lt;/span&gt;(&lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;TimerCallback&lt;/span&gt;(_Timer_Elapsed), &lt;span style="color: blue"&gt;null&lt;/span&gt;, 5000, &lt;span style="color: #2b91af"&gt;Timeout&lt;/span&gt;.Infinite);
        }

        &lt;span style="color: blue"&gt;private void &lt;/span&gt;_Timer_Elapsed(&lt;span style="color: blue"&gt;object &lt;/span&gt;data)
        {
            SendData(_Game.GetScoreData());
            &lt;span style="color: blue"&gt;int &lt;/span&gt;interval = _Random.Next(3000, 7000);
            _Timer.Change(interval, &lt;span style="color: #2b91af"&gt;Timeout&lt;/span&gt;.Infinite);
        }

        &lt;span style="color: blue"&gt;private void &lt;/span&gt;SendData(&lt;span style="color: blue"&gt;object &lt;/span&gt;data)
        {
            &lt;span style="color: #2b91af"&gt;Message &lt;/span&gt;gameDataMsg = &lt;span style="color: #2b91af"&gt;Message&lt;/span&gt;.CreateMessage(
                &lt;span style="color: #2b91af"&gt;MessageVersion&lt;/span&gt;.Soap11,
                &lt;span style="color: #a31515"&gt;&amp;quot;Silverlight/IGameStreamService/ReceiveGameData&amp;quot;&lt;/span&gt;, data);

            &lt;span style="color: green"&gt;//Send data to the client
            &lt;/span&gt;_Client.ReceiveGameData(gameDataMsg);
        }
    }
}&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;

&lt;h2&gt;
  &lt;br /&gt;Creating a Silverlight Duplex Polling Receiver Class&lt;/h2&gt;

&lt;p&gt;Calling and receiving data in Silverlight requires a fair amount of code to be written.&amp;#160; Before showing the code to interact with a polling duplex service it’s important to understand the general steps involved.&amp;#160; Here’s what you need to do to send and receive data in a Silverlight client:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Reference Assemblies and Namespaces&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Reference System.ServiceModel.dll and System.ServiceModel.PollingDuplex.dll in your Silverlight project.&amp;#160; Additional details on where to find the System.ServiceModel.PollingDuplex.dll assembly used by Silverlight can be &lt;a href="http://msdn.microsoft.com/en-us/library/cc645028(VS.95).aspx" target="_blank"&gt;found here&lt;/a&gt;.&lt;/li&gt;

  &lt;li&gt;Import the System.ServiceModel and System.ServiceModel.Channels namespaces.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Create a Factory Object&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Create a PollingDuplexHttpBinding object instance and set the PollTimeout and InactivityTimeout properties (both were discussed in &lt;a href="http://weblogs.asp.net/dwahlin/archive/2008/06/16/pushing-data-to-a-silverlight-client-with-wcf-duplex-service-part-i.aspx" target="_blank"&gt;Part 1&lt;/a&gt;).&lt;/li&gt;

  &lt;li&gt;Use the PollingDuplexHttpBinding object to build a channel factory.&lt;/li&gt;

  &lt;li&gt;Open the channel factory and define an asynchronous callback method that is called when the open completes.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Create a Channel Object&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Use the factory class to create a channel that points to the service’s HTTP endpoint.&lt;/li&gt;

  &lt;li&gt;Open the channel and define an asynchronous callback method that is called when the open completes.&lt;/li&gt;

  &lt;li&gt;Define a callback method that is called when the channel closes.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Send/Receive Messages&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Create a Message object and send it asynchronously to the service using the channel object.&amp;#160; Define an asynchronous callback method that is called when the send completes.&lt;/li&gt;

  &lt;li&gt;Start a message receive loop to listen for messages “pushed” from the service and define a callback method that is called when a message is received.&lt;/li&gt;

  &lt;li&gt;Process data pushed by the server and dispatch it to the Silverlight user interface for display.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Now that you’ve seen the fundamental steps, let’s take a look at the code that makes this process work.&amp;#160; The following code shows a class named PushDataReceiver that encapsulates the factory and channel classes and handles all of the asynchronous operations that occur.&amp;#160; The class allows an object of type IProcessor to be passed into it along with a service URL, service action and initial data to send to the service (if any).&amp;#160; The IProcessor object represents the actual Silverlight Page class used to update data on the user interface in this case.&amp;#160; As data is received the Page class’s ProcessData() method will be called.&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;using &lt;/span&gt;System;
&lt;span style="color: blue"&gt;using &lt;/span&gt;System.Net;
&lt;span style="color: blue"&gt;using &lt;/span&gt;System.ServiceModel;
&lt;span style="color: blue"&gt;using &lt;/span&gt;System.ServiceModel.Channels;
&lt;span style="color: blue"&gt;using &lt;/span&gt;System.Threading;
&lt;span style="color: blue"&gt;using &lt;/span&gt;System.IO;
&lt;span style="color: blue"&gt;using &lt;/span&gt;System.Xml.Serialization;

&lt;span style="color: blue"&gt;namespace &lt;/span&gt;SilverlightPushClient
{
    &lt;span style="color: blue"&gt;public interface &lt;/span&gt;&lt;span style="color: #2b91af"&gt;IProcessor
    &lt;/span&gt;{
        &lt;span style="color: blue"&gt;void &lt;/span&gt;ProcessData(&lt;span style="color: blue"&gt;object &lt;/span&gt;receivedData);
    }

    &lt;span style="color: blue"&gt;public class &lt;/span&gt;&lt;span style="color: #2b91af"&gt;PushDataReceiver
    &lt;/span&gt;{
        &lt;span style="color: #2b91af"&gt;SynchronizationContext &lt;/span&gt;_UiThread = &lt;span style="color: blue"&gt;null&lt;/span&gt;;
        &lt;span style="color: blue"&gt;public &lt;/span&gt;&lt;span style="color: #2b91af"&gt;IProcessor &lt;/span&gt;Client { &lt;span style="color: blue"&gt;get&lt;/span&gt;; &lt;span style="color: blue"&gt;set&lt;/span&gt;; }
        &lt;span style="color: blue"&gt;public string &lt;/span&gt;ServiceUrl { &lt;span style="color: blue"&gt;get&lt;/span&gt;; &lt;span style="color: blue"&gt;set&lt;/span&gt;; }
        &lt;span style="color: blue"&gt;public string &lt;/span&gt;Action { &lt;span style="color: blue"&gt;get&lt;/span&gt;; &lt;span style="color: blue"&gt;set&lt;/span&gt;; }
        &lt;span style="color: blue"&gt;public string &lt;/span&gt;ActionData { &lt;span style="color: blue"&gt;get&lt;/span&gt;; &lt;span style="color: blue"&gt;set&lt;/span&gt;; }

        &lt;span style="color: blue"&gt;public &lt;/span&gt;PushDataReceiver(&lt;span style="color: #2b91af"&gt;IProcessor &lt;/span&gt;client, &lt;span style="color: blue"&gt;string &lt;/span&gt;url, &lt;span style="color: blue"&gt;string &lt;/span&gt;action, &lt;span style="color: blue"&gt;string &lt;/span&gt;actionData)
        {
            Client = client;
            ServiceUrl = url;
            Action = action;
            ActionData = actionData;
            _UiThread = &lt;span style="color: #2b91af"&gt;SynchronizationContext&lt;/span&gt;.Current;
        }

        &lt;span style="color: blue"&gt;public void &lt;/span&gt;Start()
        {
            &lt;span style="color: green"&gt;// Instantiate the binding and set the time-outs
            &lt;/span&gt;&lt;span style="color: #2b91af"&gt;PollingDuplexHttpBinding &lt;/span&gt;binding = &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;PollingDuplexHttpBinding&lt;/span&gt;()
            {
                PollTimeout = &lt;span style="color: #2b91af"&gt;TimeSpan&lt;/span&gt;.FromSeconds(10),
                InactivityTimeout = &lt;span style="color: #2b91af"&gt;TimeSpan&lt;/span&gt;.FromMinutes(1)
            };

            &lt;span style="color: green"&gt;// Instantiate and open channel factory from binding
            &lt;/span&gt;&lt;span style="color: #2b91af"&gt;IChannelFactory&lt;/span&gt;&amp;lt;&lt;span style="color: #2b91af"&gt;IDuplexSessionChannel&lt;/span&gt;&amp;gt; factory =
                binding.BuildChannelFactory&amp;lt;&lt;span style="color: #2b91af"&gt;IDuplexSessionChannel&lt;/span&gt;&amp;gt;(&lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;BindingParameterCollection&lt;/span&gt;());

            &lt;span style="color: #2b91af"&gt;IAsyncResult &lt;/span&gt;factoryOpenResult =
                factory.BeginOpen(&lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;AsyncCallback&lt;/span&gt;(OnOpenCompleteFactory), factory);
            &lt;span style="color: blue"&gt;if &lt;/span&gt;(factoryOpenResult.CompletedSynchronously)
            {
                CompleteOpenFactory(factoryOpenResult);
            }
        }

        &lt;span style="color: blue"&gt;void &lt;/span&gt;OnOpenCompleteFactory(&lt;span style="color: #2b91af"&gt;IAsyncResult &lt;/span&gt;result)
        {
            &lt;span style="color: blue"&gt;if &lt;/span&gt;(result.CompletedSynchronously)
                &lt;span style="color: blue"&gt;return&lt;/span&gt;;
            &lt;span style="color: blue"&gt;else
                &lt;/span&gt;CompleteOpenFactory(result);
        }

        &lt;span style="color: blue"&gt;void &lt;/span&gt;CompleteOpenFactory(&lt;span style="color: #2b91af"&gt;IAsyncResult &lt;/span&gt;result)
        {
            &lt;span style="color: #2b91af"&gt;IChannelFactory&lt;/span&gt;&amp;lt;&lt;span style="color: #2b91af"&gt;IDuplexSessionChannel&lt;/span&gt;&amp;gt; factory =
                (&lt;span style="color: #2b91af"&gt;IChannelFactory&lt;/span&gt;&amp;lt;&lt;span style="color: #2b91af"&gt;IDuplexSessionChannel&lt;/span&gt;&amp;gt;)result.AsyncState;

            factory.EndOpen(result);

            &lt;span style="color: green"&gt;// The factory is now open. Create and open a channel from the channel factory.
            &lt;/span&gt;&lt;span style="color: #2b91af"&gt;IDuplexSessionChannel &lt;/span&gt;channel =
                factory.CreateChannel(&lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;EndpointAddress&lt;/span&gt;(ServiceUrl));

            &lt;span style="color: #2b91af"&gt;IAsyncResult &lt;/span&gt;channelOpenResult =
                channel.BeginOpen(&lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;AsyncCallback&lt;/span&gt;(OnOpenCompleteChannel), channel);
            &lt;span style="color: blue"&gt;if &lt;/span&gt;(channelOpenResult.CompletedSynchronously)
            {
                CompleteOpenChannel(channelOpenResult);
            }
        }

        &lt;span style="color: blue"&gt;void &lt;/span&gt;OnOpenCompleteChannel(&lt;span style="color: #2b91af"&gt;IAsyncResult &lt;/span&gt;result)
        {
            &lt;span style="color: blue"&gt;if &lt;/span&gt;(result.CompletedSynchronously)
                &lt;span style="color: blue"&gt;return&lt;/span&gt;;
            &lt;span style="color: blue"&gt;else
                &lt;/span&gt;CompleteOpenChannel(result);
        }

        &lt;span style="color: blue"&gt;void &lt;/span&gt;CompleteOpenChannel(&lt;span style="color: #2b91af"&gt;IAsyncResult &lt;/span&gt;result)
        {
            &lt;span style="color: #2b91af"&gt;IDuplexSessionChannel &lt;/span&gt;channel = (&lt;span style="color: #2b91af"&gt;IDuplexSessionChannel&lt;/span&gt;)result.AsyncState;

            channel.EndOpen(result);

            &lt;span style="color: green"&gt;// Channel is now open. Send message
            &lt;/span&gt;&lt;span style="color: #2b91af"&gt;Message &lt;/span&gt;message =
                &lt;span style="color: #2b91af"&gt;Message&lt;/span&gt;.CreateMessage(channel.GetProperty&amp;lt;&lt;span style="color: #2b91af"&gt;MessageVersion&lt;/span&gt;&amp;gt;(),
                 Action , ActionData);
            &lt;span style="color: #2b91af"&gt;IAsyncResult &lt;/span&gt;resultChannel =
                channel.BeginSend(message, &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;AsyncCallback&lt;/span&gt;(OnSend), channel);
            &lt;span style="color: blue"&gt;if &lt;/span&gt;(resultChannel.CompletedSynchronously)
            {
                CompleteOnSend(resultChannel);
            }

            &lt;span style="color: green"&gt;//Start listening for callbacks from the service
            &lt;/span&gt;ReceiveLoop(channel);
        }

        &lt;span style="color: blue"&gt;void &lt;/span&gt;OnSend(&lt;span style="color: #2b91af"&gt;IAsyncResult &lt;/span&gt;result)
        {
            &lt;span style="color: blue"&gt;if &lt;/span&gt;(result.CompletedSynchronously)
                &lt;span style="color: blue"&gt;return&lt;/span&gt;;
            &lt;span style="color: blue"&gt;else
                &lt;/span&gt;CompleteOnSend(result);
        }

        &lt;span style="color: blue"&gt;void &lt;/span&gt;CompleteOnSend(&lt;span style="color: #2b91af"&gt;IAsyncResult &lt;/span&gt;result)
        {
            &lt;span style="color: #2b91af"&gt;IDuplexSessionChannel &lt;/span&gt;channel = (&lt;span style="color: #2b91af"&gt;IDuplexSessionChannel&lt;/span&gt;)result.AsyncState;
            channel.EndSend(result);
        }

        &lt;span style="color: blue"&gt;void &lt;/span&gt;ReceiveLoop(&lt;span style="color: #2b91af"&gt;IDuplexSessionChannel &lt;/span&gt;channel)
        {
            &lt;span style="color: green"&gt;// Start listening for callbacks.
            &lt;/span&gt;&lt;span style="color: #2b91af"&gt;IAsyncResult &lt;/span&gt;result = channel.BeginReceive(&lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;AsyncCallback&lt;/span&gt;(OnReceiveComplete), channel);
            &lt;span style="color: blue"&gt;if &lt;/span&gt;(result.CompletedSynchronously) CompleteReceive(result);
        }

        &lt;span style="color: blue"&gt;void &lt;/span&gt;OnReceiveComplete(&lt;span style="color: #2b91af"&gt;IAsyncResult &lt;/span&gt;result)
        {
            &lt;span style="color: blue"&gt;if &lt;/span&gt;(result.CompletedSynchronously)
                &lt;span style="color: blue"&gt;return&lt;/span&gt;;
            &lt;span style="color: blue"&gt;else
                &lt;/span&gt;CompleteReceive(result);
        }

        &lt;span style="color: blue"&gt;void &lt;/span&gt;CompleteReceive(&lt;span style="color: #2b91af"&gt;IAsyncResult &lt;/span&gt;result)
        {
            &lt;span style="color: green"&gt;//A callback was received so process data
            &lt;/span&gt;&lt;span style="color: #2b91af"&gt;IDuplexSessionChannel &lt;/span&gt;channel = (&lt;span style="color: #2b91af"&gt;IDuplexSessionChannel&lt;/span&gt;)result.AsyncState;

            &lt;span style="color: blue"&gt;try
            &lt;/span&gt;{
                &lt;span style="color: #2b91af"&gt;Message &lt;/span&gt;receivedMessage = channel.EndReceive(result);

                &lt;span style="color: green"&gt;// Show the service response in the UI.
                &lt;/span&gt;&lt;span style="color: blue"&gt;if &lt;/span&gt;(receivedMessage != &lt;span style="color: blue"&gt;null&lt;/span&gt;)
                {
                    &lt;span style="color: blue"&gt;string &lt;/span&gt;text = receivedMessage.GetBody&amp;lt;&lt;span style="color: blue"&gt;string&lt;/span&gt;&amp;gt;();
                    _UiThread.Post(Client.ProcessData, text);
                }

                ReceiveLoop(channel);
            }
            &lt;span style="color: blue"&gt;catch &lt;/span&gt;(&lt;span style="color: #2b91af"&gt;CommunicationObjectFaultedException &lt;/span&gt;exp)
            {
                _UiThread.Post(&lt;span style="color: blue"&gt;delegate&lt;/span&gt;(&lt;span style="color: blue"&gt;object &lt;/span&gt;msg) { System.Windows.Browser.&lt;span style="color: #2b91af"&gt;HtmlPage&lt;/span&gt;.Window.Alert(msg.ToString()); }, exp.Message);
            }
        }

        &lt;span style="color: blue"&gt;void &lt;/span&gt;OnCloseChannel(&lt;span style="color: #2b91af"&gt;IAsyncResult &lt;/span&gt;result)
        {
            &lt;span style="color: blue"&gt;if &lt;/span&gt;(result.CompletedSynchronously)
                &lt;span style="color: blue"&gt;return&lt;/span&gt;;
            &lt;span style="color: blue"&gt;else
                &lt;/span&gt;CompleteCloseChannel(result);
        }

        &lt;span style="color: blue"&gt;void &lt;/span&gt;CompleteCloseChannel(&lt;span style="color: #2b91af"&gt;IAsyncResult &lt;/span&gt;result)
        {
            &lt;span style="color: #2b91af"&gt;IDuplexSessionChannel &lt;/span&gt;channel = (&lt;span style="color: #2b91af"&gt;IDuplexSessionChannel&lt;/span&gt;)result.AsyncState;
            channel.EndClose(result);
        }
    }
}&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;

&lt;p&gt;When the PushDataReceiver class’s Start() method is called by Silverlight it creates a channel factory instance which is used to create a channel instance.&amp;#160; The CompleteOpenChannel() callback method shown previously then sends an initial message to the service endpoint and encapsulates the data to be sent in a WCF Message object.&amp;#160; The message data is then sent along with the proper service action to call on the server.&amp;#160; After the initial message is sent a receive loop is started (see the ReceiveLoop() method) which listens for any messages sent from the server to the client and processes them accordingly.&amp;#160; Once a message is received the CompleteReceive() method is called and the message data is routed back to the Silverlight Page class.&lt;/p&gt;

&lt;h2&gt;Processing Data Using the XmlSerializer Class&lt;/h2&gt;

&lt;p&gt;The PushDataReceiver class shown earlier dispatches data received from the server back to the Silverlight Page class for processing.&amp;#160; Data sent from the server is in XML format and multiple techniques can be used to process it in Silverlight ranging from the XmlReader class to LINQ to XML functionality to the XmlSerializer class.&amp;#160; I chose to use the XmlSerializer class to process the data since it provides a simple way to map XML data to CLR types with a minimal amount of code.&amp;#160; Although you can create the CLR classes that XML data maps to by hand, I chose to create an XSD schema and use .NET’s &lt;a href="http://msdn.microsoft.com/en-us/library/x6c1kb0s(VS.80).aspx" target="_blank"&gt;xsd.exe&lt;/a&gt; tool to generate code from the schema for me.&amp;#160; The xsd.exe tool provides a simple way to generate C# or VB.NET code and ensures that the XML data will be successfully mapped to the appropriate CLR type’s properties.&amp;#160; An example of using the tool is shown next:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;xsd.exe /c /namespace:SomeNamespace Teams.xsd&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The /c switch tells the tool to generate classes (as opposed to strongly-typed DataSets) while the /namespace switch allows you to control what namespace is added into the auto-generated code.&amp;#160; Other switches are available which you can read more about &lt;a href="http://msdn.microsoft.com/en-us/library/x6c1kb0s(VS.80).aspx" target="_blank"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;One of the XSD schemas used to generate C# code with xsd.exe is shown next:&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;&amp;lt;?&lt;/span&gt;&lt;span style="color: #a31515"&gt;xml &lt;/span&gt;&lt;span style="color: red"&gt;version&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color: blue"&gt;1.0&lt;/span&gt;&amp;quot; &lt;span style="color: red"&gt;encoding&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color: blue"&gt;utf-16&lt;/span&gt;&amp;quot;&lt;span style="color: blue"&gt;?&amp;gt;
&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;xs:schema &lt;/span&gt;&lt;span style="color: red"&gt;attributeFormDefault&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color: blue"&gt;unqualified&lt;/span&gt;&amp;quot; &lt;span style="color: red"&gt;elementFormDefault&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color: blue"&gt;qualified&lt;/span&gt;&amp;quot; &lt;span style="color: red"&gt;xmlns:xs&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color: blue"&gt;http://www.w3.org/2001/XMLSchema&lt;/span&gt;&amp;quot;&lt;span style="color: blue"&gt;&amp;gt;
  &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;xs:element &lt;/span&gt;&lt;span style="color: red"&gt;name&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color: blue"&gt;Teams&lt;/span&gt;&amp;quot;&lt;span style="color: blue"&gt;&amp;gt;
    &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;xs:complexType&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
      &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;xs:sequence&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
        &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;xs:element &lt;/span&gt;&lt;span style="color: red"&gt;maxOccurs&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color: blue"&gt;unbounded&lt;/span&gt;&amp;quot; &lt;span style="color: red"&gt;name&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color: blue"&gt;Team&lt;/span&gt;&amp;quot;&lt;span style="color: blue"&gt;&amp;gt;
          &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;xs:complexType&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
            &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;xs:sequence&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
              &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;xs:element &lt;/span&gt;&lt;span style="color: red"&gt;maxOccurs&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color: blue"&gt;unbounded&lt;/span&gt;&amp;quot; &lt;span style="color: red"&gt;name&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color: blue"&gt;Player&lt;/span&gt;&amp;quot;&lt;span style="color: blue"&gt;&amp;gt;
                &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;xs:complexType&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
                  &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;xs:attribute &lt;/span&gt;&lt;span style="color: red"&gt;name&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color: blue"&gt;ID&lt;/span&gt;&amp;quot; &lt;span style="color: red"&gt;type&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color: blue"&gt;xs:string&lt;/span&gt;&amp;quot; &lt;span style="color: red"&gt;use&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color: blue"&gt;required&lt;/span&gt;&amp;quot; &lt;span style="color: blue"&gt;/&amp;gt;
                  &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;xs:attribute &lt;/span&gt;&lt;span style="color: red"&gt;name&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color: blue"&gt;Name&lt;/span&gt;&amp;quot; &lt;span style="color: red"&gt;type&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color: blue"&gt;xs:string&lt;/span&gt;&amp;quot; &lt;span style="color: red"&gt;use&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color: blue"&gt;required&lt;/span&gt;&amp;quot; &lt;span style="color: blue"&gt;/&amp;gt;
                &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;xs:complexType&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
              &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;xs:element&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
            &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;xs:sequence&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
            &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;xs:attribute &lt;/span&gt;&lt;span style="color: red"&gt;name&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color: blue"&gt;Name&lt;/span&gt;&amp;quot; &lt;span style="color: red"&gt;type&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color: blue"&gt;xs:string&lt;/span&gt;&amp;quot; &lt;span style="color: red"&gt;use&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color: blue"&gt;required&lt;/span&gt;&amp;quot; &lt;span style="color: blue"&gt;/&amp;gt;
          &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;xs:complexType&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
        &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;xs:element&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
      &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;xs:sequence&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
    &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;xs:complexType&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
  &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;xs:element&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;xs:schema&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;&lt;em&gt;Note: If you use the xsd.exe tool to generate classes that will be used in a Silverlight client you’ll have to remove a few lines that don’t compile from the auto-generated code.&amp;#160; The xsd.exe tool generates code designed to run on the full version of the .NET framework but with a few minor modifications you can also use the code with Silverlight.&amp;#160; Simply remove the namespaces and attributes that the compiler says are invalid from the auto-generated code.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Once data is received by the Silverlight client from the WCF polling duplex service it’s processed by a method named ProcessData() (the method called by the PushDataReceiver class) in the sample application.&amp;#160; ProcessData() uses the XmlSerializer class to deserialize XML data into custom Teams and ScoreData objects (the Teams and ScoreData classes were generated from XSD schemas using the xsd.exe tool mentioned earlier).&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;public void &lt;/span&gt;ProcessData(&lt;span style="color: blue"&gt;object &lt;/span&gt;receivedData)
{
    &lt;span style="color: #2b91af"&gt;StringReader &lt;/span&gt;sr = &lt;span style="color: blue"&gt;null&lt;/span&gt;;
    &lt;span style="color: blue"&gt;try
    &lt;/span&gt;{
        &lt;span style="color: blue"&gt;string &lt;/span&gt;data = (&lt;span style="color: blue"&gt;string&lt;/span&gt;)receivedData;
        sr = &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;StringReader&lt;/span&gt;(data);
        &lt;span style="color: green"&gt;//Get initial team data
        &lt;/span&gt;&lt;span style="color: blue"&gt;if &lt;/span&gt;(_Teams == &lt;span style="color: blue"&gt;null &lt;/span&gt;&amp;amp;&amp;amp; data.Contains(&lt;span style="color: #a31515"&gt;&amp;quot;Teams&amp;quot;&lt;/span&gt;))
        {
            &lt;span style="color: #2b91af"&gt;XmlSerializer &lt;/span&gt;xs = &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;XmlSerializer&lt;/span&gt;(&lt;span style="color: blue"&gt;typeof&lt;/span&gt;(&lt;span style="color: #2b91af"&gt;Teams&lt;/span&gt;));
            _Teams = (&lt;span style="color: #2b91af"&gt;Teams&lt;/span&gt;)xs.Deserialize(sr);
            UpdateBoard();
        }

        &lt;span style="color: green"&gt;//Get updated score data
        &lt;/span&gt;&lt;span style="color: blue"&gt;if &lt;/span&gt;(data.Contains(&lt;span style="color: #a31515"&gt;&amp;quot;ScoreData&amp;quot;&lt;/span&gt;))
        {
            &lt;span style="color: #2b91af"&gt;XmlSerializer &lt;/span&gt;xs = &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;XmlSerializer&lt;/span&gt;(&lt;span style="color: blue"&gt;typeof&lt;/span&gt;(&lt;span style="color: #2b91af"&gt;ScoreData&lt;/span&gt;));
            &lt;span style="color: #2b91af"&gt;ScoreData &lt;/span&gt;scoreData = (&lt;span style="color: #2b91af"&gt;ScoreData&lt;/span&gt;)xs.Deserialize(sr);
            &lt;span style="color: green"&gt;//ScoreDataHandler handler = new ScoreDataHandler(UpdateScoreData);
            //this.Dispatcher.BeginInvoke(handler, new object[] { scoreData });
            &lt;/span&gt;UpdateScoreData(scoreData);
        }
    }
    &lt;span style="color: blue"&gt;catch &lt;/span&gt;{ }
    &lt;span style="color: blue"&gt;finally
    &lt;/span&gt;{
        &lt;span style="color: blue"&gt;if &lt;/span&gt;(sr != &lt;span style="color: blue"&gt;null&lt;/span&gt;) sr.Close();
    }
}&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;

&lt;p&gt;As team and score data is pushed from the server to the client it’s updated on the Silverlight interface as shown next:&lt;/p&gt;

&lt;p&gt;&lt;img src="http://weblogs.asp.net/blogs/dwahlin/WindowsLiveWriter/UsingSilverlightandSocketstoStreamScores_148D3/SilverlightSockets_thumb_1.jpg" /&gt; &lt;/p&gt;

&lt;p&gt;The complete code for the application including the WCF duplex polling service and the Silverlight client can be &lt;a href="http://www.xmlforasp.net/CodeBank/Download/Blog/Silverlight2/SilverlightWCFPushService.zip"&gt;downloaded here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;&lt;a href="http://www.twitter.com/DanWahlin"&gt;&lt;img title="Twitter" height="60" alt="Twitter" src="http://weblogs.asp.net/blogs/dwahlin/WindowsLiveWriter/PushingDatatoaSilverlightClientwithaWCFD_89D4/Twitter_5.jpg" width="219" align="left" border="0" /&gt;&lt;/a&gt;

  &lt;br /&gt;Already on Twitter and interested in getting live updates about blog posts and other information?&amp;#160; Subscribe to my Twitter feed at &lt;a href="http://www.twitter.com/DanWahlin"&gt;http://www.twitter.com/DanWahlin&lt;/a&gt;.&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6297362" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/dwahlin/archive/tags/XML/default.aspx">XML</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/.NET/default.aspx">.NET</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/C_2300_/default.aspx">C#</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/WCF/default.aspx">WCF</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/Silverlight/default.aspx">Silverlight</category></item><item><title>Pushing Data to a Silverlight Client with a WCF Duplex Service - Part I</title><link>http://weblogs.asp.net/dwahlin/archive/2008/06/16/pushing-data-to-a-silverlight-client-with-wcf-duplex-service-part-i.aspx</link><pubDate>Mon, 16 Jun 2008 23:31:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6284094</guid><dc:creator>dwahlin</dc:creator><slash:comments>12</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/dwahlin/rsscomments.aspx?PostID=6284094</wfw:commentRss><comments>http://weblogs.asp.net/dwahlin/archive/2008/06/16/pushing-data-to-a-silverlight-client-with-wcf-duplex-service-part-i.aspx#comments</comments><description>&lt;p&gt;Silverlight provides several different ways to access data stored in remote locations.&amp;#160; Data can be pulled from Web Services and RESTful services and even pushed from servers down to clients using sockets (see my previous articles on sockets &lt;a href="http://weblogs.asp.net/dwahlin/archive/2008/04/10/pushing-data-to-a-silverlight-client-with-sockets-part-i.aspx" target="_blank" mce_href="http://weblogs.asp.net/dwahlin/archive/2008/04/10/pushing-data-to-a-silverlight-client-with-sockets-part-i.aspx"&gt;here&lt;/a&gt;, &lt;a href="http://weblogs.asp.net/dwahlin/archive/2008/04/13/pushing-data-to-a-silverlight-client-with-sockets-part-ii.aspx" target="_blank" mce_href="http://weblogs.asp.net/dwahlin/archive/2008/04/13/pushing-data-to-a-silverlight-client-with-sockets-part-ii.aspx"&gt;here&lt;/a&gt; and &lt;a href="http://weblogs.asp.net/dwahlin/archive/2008/06/08/creating-a-silverlight-2-client-access-policy-socket-server.aspx" target="_blank" mce_href="http://weblogs.asp.net/dwahlin/archive/2008/06/08/creating-a-silverlight-2-client-access-policy-socket-server.aspx"&gt;here&lt;/a&gt;).&amp;#160; Silverlight 2 Beta 2 introduces another way to push data from a server to a client using Windows Communication Foundation (WCF) and HTTP.&amp;#160; WCF's support for duplex service contracts makes this possible and opens up unique opportunities for pumping data to Silverlight clients.&amp;#160; In this first part of a two part series I'll demonstrate how a WCF push service can be created and cover the steps to get a sample service up and running.&amp;#160; The second article will focus on the client and show how to communicate with a WCF duplex service and listen for data that's sent.&lt;/p&gt;  &lt;p&gt;Many of the WCF services out there follow the simple request-response mechanism to exchange data which works well for many applications.&amp;#160; However, in addition to standard HTTP bindings, WCF also supports several others including a polling duplex binding made specifically for Silverlight which allows a service to push data down to a client as the data changes.&amp;#160; This type of binding isn't as &amp;quot;pure&amp;quot; as the push model available with sockets since the Silverlight client does poll the server to check for any queued messages, but it provides an efficient way to push data to a client without being restricted to a specific port range.&amp;#160; Once a communication channel is opened messages can be sent in either direction.&amp;#160; The Silverlight SDK states the following about how communication works between a Silverlight client and a duplex service:&amp;#160; &lt;/p&gt;  &lt;p&gt;&lt;em&gt;&amp;quot;The Silverlight client periodically polls the service on the network layer, and checks for any new messages that the service wants to send on the callback channel. The service queues all messages sent on the client callback channel and delivers them to the client when the client polls the service.&amp;quot;&lt;/em&gt;&lt;/p&gt;  &lt;h2&gt;Creating Contracts&lt;/h2&gt;  &lt;p&gt;When creating a WCF duplex service for Silverlight, the server creates a standard interface with operations.&amp;#160; However, because the server must communicate with the client it also defines a client callback interface.&amp;#160; An example of defining a server interface named IGameStreamService that includes a single service operation is shown next:&lt;/p&gt;  &lt;pre class="code"&gt;[&lt;span style="color: #2b91af"&gt;ServiceContract&lt;/span&gt;(Namespace = &lt;span style="color: #a31515"&gt;&amp;quot;Silverlight&amp;quot;&lt;/span&gt;, CallbackContract = &lt;span style="color: blue"&gt;typeof&lt;/span&gt;(&lt;span style="color: #2b91af"&gt;IGameStreamClient&lt;/span&gt;))]
&lt;span style="color: blue"&gt;public interface &lt;/span&gt;&lt;span style="color: #2b91af"&gt;IGameStreamService
&lt;/span&gt;{
    [&lt;span style="color: #2b91af"&gt;OperationContract&lt;/span&gt;(IsOneWay = &lt;span style="color: blue"&gt;true&lt;/span&gt;)]
    &lt;span style="color: blue"&gt;void &lt;/span&gt;GetGameData(&lt;span style="color: #2b91af"&gt;Message &lt;/span&gt;receivedMessage);
}&lt;/pre&gt;

&lt;p&gt;
  &lt;br /&gt;This interface is a little different from the standard WCF interfaces you may have seen or created.&amp;#160; First, it includes a CallbackContract property that points to the client interface.&amp;#160; Second, the GetGameData() operation is defined as a one way operation.&amp;#160; Client calls are not immediately returned as a result of setting IsOneWay to true and are pushed to the client instead.&amp;#160; The IGameStreamClient interface assigned to the CallbackContract is shown next.&amp;#160; It allows a message to be sent back to the client by calling the ReceiveGameData() method.&lt;/p&gt;

&lt;pre class="code"&gt;[&lt;span style="color: #2b91af"&gt;ServiceContract&lt;/span&gt;]
&lt;span style="color: blue"&gt;public interface &lt;/span&gt;&lt;span style="color: #2b91af"&gt;IGameStreamClient
&lt;/span&gt;{
    [&lt;span style="color: #2b91af"&gt;OperationContract&lt;/span&gt;(IsOneWay = &lt;span style="color: blue"&gt;true&lt;/span&gt;)]
    &lt;span style="color: blue"&gt;void &lt;/span&gt;ReceiveGameData(&lt;span style="color: #2b91af"&gt;Message &lt;/span&gt;returnMessage);
}&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste" mce_href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;

&lt;h2&gt;Creating the Service&lt;/h2&gt;

&lt;p&gt;Once the server and client contracts are defined a service class can be created that implements the IGameStreamService interface.&amp;#160; The following code creates a service that simulates a basketball game (similar to the one I demonstrated for using Sockets with Silverlight) and sends game updates to a Silverlight client on a timed basis.&amp;#160; &lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;using &lt;/span&gt;System;
&lt;span style="color: blue"&gt;using &lt;/span&gt;System.ServiceModel;
&lt;span style="color: blue"&gt;using &lt;/span&gt;System.ServiceModel.Channels;
&lt;span style="color: blue"&gt;using &lt;/span&gt;System.Threading;

&lt;span style="color: blue"&gt;namespace &lt;/span&gt;WCFPushService
{
    &lt;span style="color: blue"&gt;public class &lt;/span&gt;&lt;span style="color: #2b91af"&gt;GameStreamService &lt;/span&gt;: &lt;span style="color: #2b91af"&gt;IGameStreamService
    &lt;/span&gt;{
        &lt;span style="color: #2b91af"&gt;IGameStreamClient &lt;/span&gt;_Client;
        &lt;span style="color: #2b91af"&gt;Game &lt;/span&gt;_Game = &lt;span style="color: blue"&gt;null&lt;/span&gt;;
        &lt;span style="color: #2b91af"&gt;Timer &lt;/span&gt;_Timer = &lt;span style="color: blue"&gt;null&lt;/span&gt;;
        &lt;span style="color: #2b91af"&gt;Random &lt;/span&gt;_Random = &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;Random&lt;/span&gt;();

        &lt;span style="color: blue"&gt;public &lt;/span&gt;GameStreamService()
        {
            _Game = &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;Game&lt;/span&gt;();
        }

        &lt;span style="color: blue"&gt;public void &lt;/span&gt;GetGameData(&lt;span style="color: #2b91af"&gt;Message &lt;/span&gt;receivedMessage)
        {

            &lt;span style="color: green"&gt;//Get client callback channel
            &lt;/span&gt;_Client = &lt;span style="color: #2b91af"&gt;OperationContext&lt;/span&gt;.Current.GetCallbackChannel&amp;lt;&lt;span style="color: #2b91af"&gt;IGameStreamClient&lt;/span&gt;&amp;gt;();

            SendData(_Game.GetTeamData());
            &lt;span style="color: green"&gt;//Start timer which when fired sends updated score information to client
            &lt;/span&gt;_Timer = &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;Timer&lt;/span&gt;(&lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;TimerCallback&lt;/span&gt;(_Timer_Elapsed), &lt;span style="color: blue"&gt;null&lt;/span&gt;, 5000, &lt;span style="color: #2b91af"&gt;Timeout&lt;/span&gt;.Infinite);
        }

        &lt;span style="color: blue"&gt;private void &lt;/span&gt;_Timer_Elapsed(&lt;span style="color: blue"&gt;object &lt;/span&gt;data)
        {
            SendData(_Game.GetScoreData());
            &lt;span style="color: blue"&gt;int &lt;/span&gt;interval = _Random.Next(3000, 7000);
            _Timer.Change(interval, &lt;span style="color: #2b91af"&gt;Timeout&lt;/span&gt;.Infinite);
        }

        &lt;span style="color: blue"&gt;private void &lt;/span&gt;SendData(&lt;span style="color: blue"&gt;object &lt;/span&gt;data)
        {
            &lt;span style="color: #2b91af"&gt;Message &lt;/span&gt;gameDataMsg = &lt;span style="color: #2b91af"&gt;Message&lt;/span&gt;.CreateMessage(
                &lt;span style="color: #2b91af"&gt;MessageVersion&lt;/span&gt;.Soap11,
                &lt;span style="color: #a31515"&gt;&amp;quot;Silverlight/IGameStreamService/ReceiveGameData&amp;quot;&lt;/span&gt;, data);

            &lt;span style="color: green"&gt;//Send data to the client
            &lt;/span&gt;_Client.ReceiveGameData(gameDataMsg);
        }
    }
}&lt;/pre&gt;

&lt;p&gt;
  &lt;br /&gt;The service first creates an instance of a Game class in the constructor which handles simulating a basketball game and creating new data that can be sent to the client.&amp;#160; Once the client calls the service's GetGameData() operation (a one-way operation), access to the client's callback interface is retrieved by going through the OperationContext object and calling the GetCallbackChannel() method.&amp;#160; The teams involved in the game are then created on the server and pushed to the client by calling the SendData() method.&amp;#160; This method calls the Game object's GetTeamData() method.&amp;#160; Although not shown here (but included in the sample code), the GetTeamData() method generates an XML message and returns it as a string.&amp;#160; The SendData() method then creates a WCF Message object, defines that SOAP 1.1 will be used (required for this type of communication) and defines the proper action to be used to send the XML data to the client.&amp;#160; The client's ReceiveGameData() operation is then called and the message is ultimately sent to the client.&amp;#160; &lt;/p&gt;

&lt;p&gt;Once the client receives the team data the server will start sending simulated score data on a random basis.&amp;#160; When the Timer object created in the initial call to GetGameData() fires the _Timer_Elapsed() method is called which gets updated score information and pushes it to the Silverlight client by calling the SendData() method.&lt;/p&gt;

&lt;h2&gt;Creating the Service Factory&lt;/h2&gt;

&lt;p&gt;Once the service class is created a service factory can be created along with a service host.&amp;#160; The factory is responsible for creating the appropriate host while the host defines the service endpoint.&amp;#160; An example of creating service factory and host classes is shown next:&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;using &lt;/span&gt;System;
&lt;span style="color: blue"&gt;using &lt;/span&gt;System.ServiceModel;
&lt;span style="color: blue"&gt;using &lt;/span&gt;System.ServiceModel.Activation;
&lt;span style="color: blue"&gt;using &lt;/span&gt;System.ServiceModel.Channels;
&lt;span style="color: blue"&gt;using &lt;/span&gt;System.ServiceModel.Configuration;

&lt;span style="color: blue"&gt;namespace &lt;/span&gt;WCFPushService
{
    &lt;span style="color: blue"&gt;public class &lt;/span&gt;&lt;span style="color: #2b91af"&gt;PollingDuplexServiceHostFactory &lt;/span&gt;: &lt;span style="color: #2b91af"&gt;ServiceHostFactoryBase
    &lt;/span&gt;{
        &lt;span style="color: blue"&gt;public override &lt;/span&gt;&lt;span style="color: #2b91af"&gt;ServiceHostBase &lt;/span&gt;CreateServiceHost(&lt;span style="color: blue"&gt;string &lt;/span&gt;constructorString,
            &lt;span style="color: #2b91af"&gt;Uri&lt;/span&gt;[] baseAddresses)
        {
            &lt;span style="color: blue"&gt;return new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;PollingDuplexServiceHost&lt;/span&gt;(baseAddresses);
        }
    }

    &lt;span style="color: blue"&gt;class &lt;/span&gt;&lt;span style="color: #2b91af"&gt;PollingDuplexServiceHost &lt;/span&gt;: &lt;span style="color: #2b91af"&gt;ServiceHost
    &lt;/span&gt;{
        &lt;span style="color: blue"&gt;public &lt;/span&gt;PollingDuplexServiceHost(&lt;span style="color: blue"&gt;params &lt;/span&gt;System.&lt;span style="color: #2b91af"&gt;Uri&lt;/span&gt;[] addresses)
        {
            &lt;span style="color: blue"&gt;base&lt;/span&gt;.InitializeDescription(&lt;span style="color: blue"&gt;typeof&lt;/span&gt;(&lt;span style="color: #2b91af"&gt;GameStreamService&lt;/span&gt;), &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;UriSchemeKeyedCollection&lt;/span&gt;(addresses));
        }

        &lt;span style="color: blue"&gt;protected override void &lt;/span&gt;InitializeRuntime()
        {
            &lt;span style="color: green"&gt;// Define the binding and set time-outs
            &lt;/span&gt;&lt;span style="color: #2b91af"&gt;PollingDuplexBindingElement &lt;/span&gt;bindingElement = &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;PollingDuplexBindingElement&lt;/span&gt;()
            {
                PollTimeout = &lt;span style="color: #2b91af"&gt;TimeSpan&lt;/span&gt;.FromSeconds(10),
                InactivityTimeout = &lt;span style="color: #2b91af"&gt;TimeSpan&lt;/span&gt;.FromMinutes(1)
            };

            &lt;span style="color: green"&gt;// Add an endpoint for the given service contract
            &lt;/span&gt;&lt;span style="color: blue"&gt;this&lt;/span&gt;.AddServiceEndpoint(
                &lt;span style="color: blue"&gt;typeof&lt;/span&gt;(&lt;span style="color: #2b91af"&gt;IGameStreamService&lt;/span&gt;),
                &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;CustomBinding&lt;/span&gt;(
                    bindingElement,
                    &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;TextMessageEncodingBindingElement&lt;/span&gt;(
                        &lt;span style="color: #2b91af"&gt;MessageVersion&lt;/span&gt;.Soap11,
                        System.Text.&lt;span style="color: #2b91af"&gt;Encoding&lt;/span&gt;.UTF8),
                    &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;HttpTransportBindingElement&lt;/span&gt;()),
                    &lt;span style="color: #a31515"&gt;&amp;quot;&amp;quot;&lt;/span&gt;);

            &lt;span style="color: blue"&gt;base&lt;/span&gt;.InitializeRuntime();
        }
    }
}&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste" mce_href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;

&lt;p&gt;
  &lt;br /&gt;This code was pulled directly from the &lt;a href="http://msdn.microsoft.com/en-us/library/cc645027(VS.95).aspx" target="_blank" mce_href="http://msdn.microsoft.com/en-us/library/cc645027(VS.95).aspx"&gt;Silverlight SDK example&lt;/a&gt; which provides a great starting point for creating WCF/Silverlight polling duplex services.&amp;#160; The service factory class (PollingDuplexServiceHostFactory) creates a new instance of the service host class (PollingDuplexServiceHost) within the CreateServiceHost() method.&amp;#160; The service host class then overrides the InitializeRuntime() method and creates a PollingDuplexBindingElement instance which defines the client's polling and inactivity timeouts.&amp;#160; The Silverlight SDK states the following about the PollingDuplexBindingElement class's PollTimeout and InactivityTimeout properties:&lt;/p&gt;

&lt;p&gt;&lt;em&gt;&amp;quot;The PollTimeout property determines the length of time (in milliseconds) that the service holds a poll from the client before returning. The InactivityTimeout property determines the length of time (in milliseconds) that can elapse without any message exchange with the client before the service closes its session.&amp;quot;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The PollingDuplexBindingElement class is located in an assembly named System.ServiceModel.PollingDuplex.dll which is part of the Silverlight SDK.&amp;#160; You'll need to reference the assembly in your WCF project as well as the System.ServiceModel.Channels namespace to use the PollingDuplexBindingElement class.&amp;#160; Once the binding element is created a call is made to the host object's AddServiceEndPoint() method which references the PollingDuplexBindingElement object and the server's IGameStreamService interface to create a custom binding that uses HTTP under the covers for message exchange.&lt;/p&gt;

&lt;p&gt;Once the factory and service classes are created the factory can be referenced in the service's .svc file in the following manner:&lt;/p&gt;

&lt;pre class="code"&gt;&amp;lt;%@ ServiceHost Language=&amp;quot;C#&amp;quot; Factory=&amp;quot;WCFPushService.PollingDuplexServiceHostFactory&amp;quot; %&amp;gt;&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste" mce_href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;

&lt;p&gt;
  &lt;br /&gt;Looking through all of the code you can see that there's definitely some initial setup work required to get a Silverlight callable WCF duplex service created.&amp;#160; Since the client does have to poll the service to check for queued messages you may wonder what the benefit is over writing a manual polling Silverlight client that calls a WCF service.&amp;#160; Microsoft's &lt;a href="http://weblogs.asp.net/scottgu" target="_blank" mce_href="http://weblogs.asp.net/scottgu"&gt;Scott Guthrie&lt;/a&gt; was kind enough to provide additional details on that subject.&amp;#160; Here's what he had to say:&lt;/p&gt;

&lt;p&gt;&lt;em&gt;&amp;quot;The duplex support does use polling in the background to implement notifications – although the way it does it is different than manual polling. It initiates a network request, and then the request is effectively “put to sleep” waiting for the server to respond (it doesn’t come back immediately). The server then keeps the connection open but not active until it has something to send back (or the connection times out after 90 seconds – at which point the duplex client will connect again and wait). This way you are avoiding hitting the server repeatedly – but still get an immediate response when there is data to send.&amp;quot;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;When the client polls in the background it sends the following message to the server:&lt;/p&gt;

&lt;pre class="code"&gt;&amp;lt;s:Envelope xmlns:s=&lt;span style="color: #a31515"&gt;&amp;quot;http://schemas.xmlsoap.org/soap/envelope/&amp;quot;&lt;/span&gt;&amp;gt;
    &amp;lt;s:Body&amp;gt;
        &amp;lt;wsmc:MakeConnection xmlns:wsmc=&lt;span style="color: #a31515"&gt;&amp;quot;http://docs.oasis-open.org/ws-rx/wsmc/200702&amp;quot;&lt;/span&gt;&amp;gt;
            &amp;lt;wsmc:Address&amp;gt;
                http:&lt;span style="color: green"&gt;//docs.oasis-open.org/ws-rx/wsmc/200702/anoynmous?id=7f64eefe-9328-4168-8175-1d4b82bef9c3
            &lt;/span&gt;&amp;lt;/wsmc:Address&amp;gt;
        &amp;lt;/wsmc:MakeConnection&amp;gt;
    &amp;lt;/s:Body&amp;gt;
&amp;lt;/s:Envelope&amp;gt;&lt;/pre&gt;

&lt;p&gt;
  &lt;br /&gt;In the next article I'll demonstrate how to call a WCF polling duplex service and listen for data in a Silverlight 2 application.&amp;#160; An example of the Silverlight interface that will be discussed is shown next:&lt;/p&gt;

&lt;p&gt;&lt;img height="453" src="http://weblogs.asp.net/blogs/dwahlin/WindowsLiveWriter/UsingSilverlightandSocketstoStreamScores_148D3/SilverlightSockets_thumb_1.jpg" width="532" mce_src="http://weblogs.asp.net/blogs/dwahlin/WindowsLiveWriter/UsingSilverlightandSocketstoStreamScores_148D3/SilverlightSockets_thumb_1.jpg" /&gt; &lt;/p&gt;

&lt;p&gt;In the meantime, you can download the Silverlight 2 Beta 2 sample application including the WCF service and Silverlight client &lt;a class="" href="http://www.xmlforasp.net/CodeBank/Download/Blog/Silverlight2/SilverlightWCFPushService.zip" mce_href="http://www.xmlforasp.net/CodeBank/Download/Blog/Silverlight2/SilverlightWCFPushService.zip"&gt;here&lt;/a&gt;. 

  &lt;br /&gt;

  &lt;br /&gt;

  &lt;br /&gt;

  &lt;br /&gt;

  &lt;br /&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="http://www.twitter.com/DanWahlin" target="_blank"&gt;&lt;img title="Twitter" style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="60" alt="Twitter" src="http://weblogs.asp.net/blogs/dwahlin/WindowsLiveWriter/PushingDatatoaSilverlightClientwithaWCFD_89D4/Twitter_5.jpg" width="219" align="left" border="0" /&gt;&lt;/a&gt; 

  &lt;br /&gt;Interested in getting live updates about blog posts and other information?&amp;#160; Subscribe to my Twitter feed at &lt;a href="http://www.twitter.com/DanWahlin" mce_href="http://www.twitter.com/DanWahlin"&gt;http://www.twitter.com/DanWahlin&lt;/a&gt;.&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6284094" width="1" height="1"&gt;</description></item><item><title>Creating a Silverlight 2 Client Access Policy Socket Server</title><link>http://weblogs.asp.net/dwahlin/archive/2008/06/08/creating-a-silverlight-2-client-access-policy-socket-server.aspx</link><pubDate>Mon, 09 Jun 2008 06:57:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6260434</guid><dc:creator>dwahlin</dc:creator><slash:comments>12</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/dwahlin/rsscomments.aspx?PostID=6260434</wfw:commentRss><comments>http://weblogs.asp.net/dwahlin/archive/2008/06/08/creating-a-silverlight-2-client-access-policy-socket-server.aspx#comments</comments><description>&lt;P&gt;Silverlight 2 provides built-in support for sockets which allows servers to push data to Silverlight clients.&amp;nbsp; By using this feature clients can avoid polling the server on a timed basis to ensure that clients are kept up-to-date.&amp;nbsp; If you're new to the socket features built-into Silverlight 2 you'll want to read my previous posts to get additional details about how data can be pushed from a server to a client:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;A href="http://weblogs.asp.net/dwahlin/archive/2008/04/10/pushing-data-to-a-silverlight-client-with-sockets-part-i.aspx" target=_blank mce_href="http://weblogs.asp.net/dwahlin/archive/2008/04/10/pushing-data-to-a-silverlight-client-with-sockets-part-i.aspx"&gt;Pushing Data to a Silverlight Client with Sockets: Part I&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;A href="http://weblogs.asp.net/dwahlin/archive/2008/04/13/pushing-data-to-a-silverlight-client-with-sockets-part-ii.aspx" target=_blank mce_href="http://weblogs.asp.net/dwahlin/archive/2008/04/13/pushing-data-to-a-silverlight-client-with-sockets-part-ii.aspx"&gt;Pushing Data to a Silverlight Client with Sockets: Part II&lt;/A&gt;&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;Silverlight 2 Beta 2 (and beyond) checks for a client access policy before accessing sockets located on host domain or cross-domain servers.&amp;nbsp; An example of a client access policy for sockets is shown next:&lt;/P&gt;&lt;PRE class=code&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;lt;?&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;xml &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;version&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;1.0&lt;/SPAN&gt;" &lt;SPAN style="COLOR: red"&gt;encoding &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;utf-8&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;?&amp;gt;
&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;access-policy&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;
  &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;cross-domain-access&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;
    &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;policy&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;
      &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;allow-from&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;
        &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;domain &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;uri&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;*&lt;/SPAN&gt;" &lt;SPAN style="COLOR: blue"&gt;/&amp;gt;
      &amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;allow-from&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;
      &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;grant-to&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;
        &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;socket-resource &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;port&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;4530&lt;/SPAN&gt;" &lt;SPAN style="COLOR: red"&gt;protocol&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;tcp&lt;/SPAN&gt;" &lt;SPAN style="COLOR: blue"&gt;/&amp;gt;
      &amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;grant-to&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;
    &amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;policy&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;
  &amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;cross-domain-access&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;
&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;access-policy&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;A href="http://11011.net/software/vspaste" mce_href="http://11011.net/software/vspaste"&gt;&lt;/A&gt;
&lt;P&gt;This XML code allows Silverlight to access a TCP socket on port 4530.&amp;nbsp; A range of ports can be specified in the &lt;EM&gt;port&lt;/EM&gt; attribute if needed (ex: 4530-4532).&amp;nbsp; Before Silverlight tries to call a server with a socket, it makes a call to the target server on port 943 to check the client access policy and see if the server allows socket connections.&amp;nbsp; This helps minimize various types of hacker attacks.&amp;nbsp; If a client access policy is available on the server and the policy allows access to the port the client is trying to call, processing of the socket code continues and Silverlight tries to connect.&amp;nbsp; If not, the client will be unable to connect due to access being denied by Silverlight.&lt;/P&gt;
&lt;P&gt;An example of creating a client access policy socket server that Silverlight can connect to on port 943 is shown next:&lt;/P&gt;&lt;PRE class=code&gt;&lt;SPAN style="COLOR: blue"&gt;using &lt;/SPAN&gt;System;
&lt;SPAN style="COLOR: blue"&gt;using &lt;/SPAN&gt;System.Collections.Generic;
&lt;SPAN style="COLOR: blue"&gt;using &lt;/SPAN&gt;System.Text;
&lt;SPAN style="COLOR: blue"&gt;using &lt;/SPAN&gt;System.Net;
&lt;SPAN style="COLOR: blue"&gt;using &lt;/SPAN&gt;System.Net.Sockets;
&lt;SPAN style="COLOR: blue"&gt;using &lt;/SPAN&gt;System.IO;
&lt;SPAN style="COLOR: blue"&gt;using &lt;/SPAN&gt;System.Threading;
&lt;SPAN style="COLOR: blue"&gt;using &lt;/SPAN&gt;System.Reflection;
&lt;SPAN style="COLOR: blue"&gt;using &lt;/SPAN&gt;System.Configuration;

&lt;SPAN style="COLOR: blue"&gt;namespace &lt;/SPAN&gt;PolicySocketServices
{
    &lt;SPAN style="COLOR: blue"&gt;class &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;PolicySocketServer
    &lt;/SPAN&gt;{
        &lt;SPAN style="COLOR: #2b91af"&gt;TcpListener &lt;/SPAN&gt;_Listener = &lt;SPAN style="COLOR: blue"&gt;null&lt;/SPAN&gt;;
        &lt;SPAN style="COLOR: #2b91af"&gt;TcpClient &lt;/SPAN&gt;_Client = &lt;SPAN style="COLOR: blue"&gt;null&lt;/SPAN&gt;;
        &lt;SPAN style="COLOR: blue"&gt;static &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;ManualResetEvent &lt;/SPAN&gt;_TcpClientConnected = &lt;SPAN style="COLOR: blue"&gt;new &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;ManualResetEvent&lt;/SPAN&gt;(&lt;SPAN style="COLOR: blue"&gt;false&lt;/SPAN&gt;);
        &lt;SPAN style="COLOR: blue"&gt;const string &lt;/SPAN&gt;_PolicyRequestString = &lt;SPAN style="COLOR: #a31515"&gt;"&amp;lt;policy-file-request/&amp;gt;"&lt;/SPAN&gt;;
        &lt;SPAN style="COLOR: blue"&gt;int &lt;/SPAN&gt;_ReceivedLength = 0;
        &lt;SPAN style="COLOR: blue"&gt;byte&lt;/SPAN&gt;[] _Policy = &lt;SPAN style="COLOR: blue"&gt;null&lt;/SPAN&gt;;
        &lt;SPAN style="COLOR: blue"&gt;byte&lt;/SPAN&gt;[] _ReceiveBuffer = &lt;SPAN style="COLOR: blue"&gt;null&lt;/SPAN&gt;;

        &lt;SPAN style="COLOR: blue"&gt;private void &lt;/SPAN&gt;InitializeData()
        {
            &lt;SPAN style="COLOR: blue"&gt;string &lt;/SPAN&gt;policyFile = &lt;SPAN style="COLOR: #2b91af"&gt;ConfigurationManager&lt;/SPAN&gt;.AppSettings[&lt;SPAN style="COLOR: #a31515"&gt;"PolicyFilePath"&lt;/SPAN&gt;];
            &lt;SPAN style="COLOR: blue"&gt;using &lt;/SPAN&gt;(&lt;SPAN style="COLOR: #2b91af"&gt;FileStream &lt;/SPAN&gt;fs = &lt;SPAN style="COLOR: blue"&gt;new &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;FileStream&lt;/SPAN&gt;(policyFile, &lt;SPAN style="COLOR: #2b91af"&gt;FileMode&lt;/SPAN&gt;.Open))
            {
                _Policy = &lt;SPAN style="COLOR: blue"&gt;new byte&lt;/SPAN&gt;[fs.Length];
                fs.Read(_Policy, 0, _Policy.Length);
            }
            _ReceiveBuffer = &lt;SPAN style="COLOR: blue"&gt;new byte&lt;/SPAN&gt;[_PolicyRequestString.Length];
        }

        &lt;SPAN style="COLOR: blue"&gt;public void &lt;/SPAN&gt;StartSocketServer()
        {
            InitializeData();

            &lt;SPAN style="COLOR: blue"&gt;try
            &lt;/SPAN&gt;{
                &lt;SPAN style="COLOR: green"&gt;//Using TcpListener which is a wrapper around a Socket
                //Allowed port is 943 for Silverlight sockets policy data
                &lt;/SPAN&gt;_Listener = &lt;SPAN style="COLOR: blue"&gt;new &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;TcpListener&lt;/SPAN&gt;(&lt;SPAN style="COLOR: #2b91af"&gt;IPAddress&lt;/SPAN&gt;.Any, 943);
                _Listener.Start();
                &lt;SPAN style="COLOR: #2b91af"&gt;Console&lt;/SPAN&gt;.WriteLine(&lt;SPAN style="COLOR: #a31515"&gt;"Policy server listening..."&lt;/SPAN&gt;);
                &lt;SPAN style="COLOR: blue"&gt;while &lt;/SPAN&gt;(&lt;SPAN style="COLOR: blue"&gt;true&lt;/SPAN&gt;)
                {
                    _TcpClientConnected.Reset();
                    &lt;SPAN style="COLOR: #2b91af"&gt;Console&lt;/SPAN&gt;.WriteLine(&lt;SPAN style="COLOR: #a31515"&gt;"Waiting for client connection..."&lt;/SPAN&gt;);
                    _Listener.BeginAcceptTcpClient(&lt;SPAN style="COLOR: blue"&gt;new &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;AsyncCallback&lt;/SPAN&gt;(OnBeginAccept), &lt;SPAN style="COLOR: blue"&gt;null&lt;/SPAN&gt;);
                    _TcpClientConnected.WaitOne(); &lt;SPAN style="COLOR: green"&gt;//Block until client connects
                &lt;/SPAN&gt;}
            }
            &lt;SPAN style="COLOR: blue"&gt;catch &lt;/SPAN&gt;(&lt;SPAN style="COLOR: #2b91af"&gt;Exception &lt;/SPAN&gt;exp)
            {
                LogError(exp);
            }
        }

        &lt;SPAN style="COLOR: blue"&gt;private void &lt;/SPAN&gt;OnBeginAccept(&lt;SPAN style="COLOR: #2b91af"&gt;IAsyncResult &lt;/SPAN&gt;ar)
        {
            _Client = _Listener.EndAcceptTcpClient(ar);
            _Client.Client.BeginReceive(_ReceiveBuffer, 0, _PolicyRequestString.Length, &lt;SPAN style="COLOR: #2b91af"&gt;SocketFlags&lt;/SPAN&gt;.None,
                &lt;SPAN style="COLOR: blue"&gt;new &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;AsyncCallback&lt;/SPAN&gt;(OnReceiveComplete), &lt;SPAN style="COLOR: blue"&gt;null&lt;/SPAN&gt;);
        }

        &lt;SPAN style="COLOR: blue"&gt;private void &lt;/SPAN&gt;OnReceiveComplete(&lt;SPAN style="COLOR: #2b91af"&gt;IAsyncResult &lt;/SPAN&gt;ar)
        {
            &lt;SPAN style="COLOR: blue"&gt;try
            &lt;/SPAN&gt;{
                _ReceivedLength += _Client.Client.EndReceive(ar);
                &lt;SPAN style="COLOR: green"&gt;//See if there's more data that we need to grab
                &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;if &lt;/SPAN&gt;(_ReceivedLength &amp;lt; _PolicyRequestString.Length)
                {
                    &lt;SPAN style="COLOR: green"&gt;//Need to grab more data so receive remaining data
                    &lt;/SPAN&gt;_Client.Client.BeginReceive(_ReceiveBuffer, _ReceivedLength, 
                        _PolicyRequestString.Length - _ReceivedLength,
                        &lt;SPAN style="COLOR: #2b91af"&gt;SocketFlags&lt;/SPAN&gt;.None, &lt;SPAN style="COLOR: blue"&gt;new &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;AsyncCallback&lt;/SPAN&gt;(OnReceiveComplete), &lt;SPAN style="COLOR: blue"&gt;null&lt;/SPAN&gt;);
                    &lt;SPAN style="COLOR: blue"&gt;return&lt;/SPAN&gt;;
                }

                &lt;SPAN style="COLOR: green"&gt;//Check that &amp;lt;policy-file-request/&amp;gt; was sent from client
                &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;string &lt;/SPAN&gt;request = System.Text.&lt;SPAN style="COLOR: #2b91af"&gt;Encoding&lt;/SPAN&gt;.UTF8.GetString(_ReceiveBuffer, 0, _ReceivedLength);
                &lt;SPAN style="COLOR: blue"&gt;if &lt;/SPAN&gt;(&lt;SPAN style="COLOR: #2b91af"&gt;StringComparer&lt;/SPAN&gt;.InvariantCultureIgnoreCase.Compare(request, _PolicyRequestString) != 0)
                {
                    &lt;SPAN style="COLOR: green"&gt;//Data received isn't valid so close
                    &lt;/SPAN&gt;_Client.Client.Close();
                    &lt;SPAN style="COLOR: blue"&gt;return&lt;/SPAN&gt;;
                }
                &lt;SPAN style="COLOR: green"&gt;//Valid request received....send policy data
                &lt;/SPAN&gt;_Client.Client.BeginSend(_Policy, 0, _Policy.Length, &lt;SPAN style="COLOR: #2b91af"&gt;SocketFlags&lt;/SPAN&gt;.None, 
                    &lt;SPAN style="COLOR: blue"&gt;new &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;AsyncCallback&lt;/SPAN&gt;(OnSendComplete), &lt;SPAN style="COLOR: blue"&gt;null&lt;/SPAN&gt;);
            }
            &lt;SPAN style="COLOR: blue"&gt;catch &lt;/SPAN&gt;(&lt;SPAN style="COLOR: #2b91af"&gt;Exception &lt;/SPAN&gt;exp)
            {
                _Client.Client.Close();
                LogError(exp);
            }
            _ReceivedLength = 0;
            _TcpClientConnected.Set(); &lt;SPAN style="COLOR: green"&gt;//Allow waiting thread to proceed
        &lt;/SPAN&gt;}

        &lt;SPAN style="COLOR: blue"&gt;private void &lt;/SPAN&gt;OnSendComplete(&lt;SPAN style="COLOR: #2b91af"&gt;IAsyncResult &lt;/SPAN&gt;ar)
        {
            &lt;SPAN style="COLOR: blue"&gt;try
            &lt;/SPAN&gt;{
                _Client.Client.EndSendFile(ar);
            }
            &lt;SPAN style="COLOR: blue"&gt;catch &lt;/SPAN&gt;(&lt;SPAN style="COLOR: #2b91af"&gt;Exception &lt;/SPAN&gt;exp)
            {
                LogError(exp);
            }
            &lt;SPAN style="COLOR: blue"&gt;finally            
            &lt;/SPAN&gt;{
                &lt;SPAN style="COLOR: green"&gt;//Close client socket
                &lt;/SPAN&gt;_Client.Client.Close();
            } 
        }

        &lt;SPAN style="COLOR: blue"&gt;private void &lt;/SPAN&gt;LogError(&lt;SPAN style="COLOR: #2b91af"&gt;Exception &lt;/SPAN&gt;exp)
        {
            &lt;SPAN style="COLOR: blue"&gt;string &lt;/SPAN&gt;appFullPath = &lt;SPAN style="COLOR: #2b91af"&gt;Assembly&lt;/SPAN&gt;.GetCallingAssembly().Location;
            &lt;SPAN style="COLOR: blue"&gt;string &lt;/SPAN&gt;logPath = appFullPath.Substring(0, appFullPath.LastIndexOf(&lt;SPAN style="COLOR: #a31515"&gt;"\\"&lt;/SPAN&gt;)) + &lt;SPAN style="COLOR: #a31515"&gt;".log"&lt;/SPAN&gt;;
            &lt;SPAN style="COLOR: #2b91af"&gt;StreamWriter &lt;/SPAN&gt;writer = &lt;SPAN style="COLOR: blue"&gt;new &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;StreamWriter&lt;/SPAN&gt;(logPath, &lt;SPAN style="COLOR: blue"&gt;true&lt;/SPAN&gt;);
            &lt;SPAN style="COLOR: blue"&gt;try
            &lt;/SPAN&gt;{
                writer.WriteLine(logPath,
                    &lt;SPAN style="COLOR: #2b91af"&gt;String&lt;/SPAN&gt;.Format(&lt;SPAN style="COLOR: #a31515"&gt;"Error in PolicySocketServer: "
                    &lt;/SPAN&gt;+ &lt;SPAN style="COLOR: #a31515"&gt;"{0} \r\n StackTrace: {1}"&lt;/SPAN&gt;, exp.Message, exp.StackTrace));
            }
            &lt;SPAN style="COLOR: blue"&gt;catch &lt;/SPAN&gt;{ }
            &lt;SPAN style="COLOR: blue"&gt;finally
            &lt;/SPAN&gt;{
                writer.Close();
            }
        }
    }
}&lt;BR&gt;&lt;/PRE&gt;&lt;A href="http://11011.net/software/vspaste" mce_href="http://11011.net/software/vspaste"&gt;&lt;/A&gt;
&lt;P&gt;Looking through the code you'll see that it uses the TcpListener class to listen for incoming client connections.&amp;nbsp; Once a client connects the code checks the request for the following value:&lt;/P&gt;&lt;PRE class=code&gt;&lt;SPAN style="COLOR: #a31515"&gt;&amp;lt;policy-file-request/&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;A href="http://11011.net/software/vspaste" mce_href="http://11011.net/software/vspaste"&gt;&lt;/A&gt;Silverlight automatically sends this text to the policy file socket once it connects.&amp;nbsp; If the request contains the proper value the code writes the contents of the client access policy back to the client stream (see the OnReceiveComplete() method).&amp;nbsp; Once the policy file is received, Silverlight parses it, checks that it allows access to the desired port, and then accepts or rejects the socket call that the application is trying to make.&amp;nbsp; &lt;/P&gt;
&lt;P&gt;An example of the Silverlight GameStream socket application I created to demonstrate the fundamentals of using sockets is shown next.&amp;nbsp; The code for the application can be &lt;A href="http://www.xmlforasp.net/CodeBank/Download/Blog/Silverlight2/SilverlightSockets.zip" target=_blank mce_href="http://www.xmlforasp.net/CodeBank/Download/Blog/Silverlight2/SilverlightSockets.zip"&gt;downloaded here&lt;/A&gt;.&amp