<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="https://www.w3.org/2005/Atom" xmlns:sy="https://purl.org/rss/1.0/modules/syndication/" xmlns:dc="https://purl.org/dc/elements/1.1/" xmlns:content="https://purl.org/rss/1.0/modules/content/" xmlns:wfw="https://wellformedweb.org/CommentAPI/" xmlns:slash="https://purl.org/rss/1.0/modules/slash/"
  version="2.0">
  <channel>
    <title>Brett Robinson's Blog</title>
    <atom:link
      href="https://docs.microsoft.com/archive/blogs/brettrobinson/feed.xml"
      rel="self"
      type="application/rss+xml" />
    <link>https://docs.microsoft.com/archive/blogs/brettrobinson/feed.xml</link>
    <description>Brett Robinson&amp;#039;s Technical blog at Microsoft</description>
    <lastBuildDate>Wed, 17 Apr 2019 03:18:52 GMT</lastBuildDate>
    <language>en-US</language>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>1</sy:updateFrequency>
    <item>
      <title>ATI driver and windows 10</title>
      <link>https://docs.microsoft.com/archive/blogs/brettrobinson/ati-driver-and-windows-10</link>
      <pubDate>Tue, 24 Nov 2015 10:28:00 GMT</pubDate>
      <dc:creator><![CDATA[Brett Robinson]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/brettrobinson/2015/11/24/ati-driver-and-windows-10/</guid>
      <description><![CDATA[This is kind of a reminder for me as well as maybe something that can help others also.
My computer...]]></description>
      <content:encoded><![CDATA[<p>This is kind of a reminder for me as well as maybe something that can help others also.</p>
<p>My computer was recently upgraded to Windows 10 and when that happened it decided to use the Microsoft Basic Display adapter instead of my legacy ATI radeon 4800 driver.&nbsp; It had the incorrect resolution and did not detect my dual monitor.</p>
<p>When looking at my display adapter settings in device manager, it did show the display adapter correctly, so that wasn't the issue.&nbsp; If your adapter is not showing, I heard you can do an uninstall to let the plug in play manager detect it again.&nbsp; Or update the driver and chose your drivers inf file.&nbsp; But that wasn't my problem, so here's what I did:</p>
<ol>
<li>right click the display adapter and choose properties</li>
<li>Click update driver</li>
<li>Choose browse my computer for driver software</li>
<li>choose let me pick of device drivers on my computer</li>
<li>From there I was presented with a list and I went to the previous version of the driver and clicked it</li>
</ol>
<p>That worked for me, the correct resolution was now on my monitor and my dual monitor was detected.</p>]]></content:encoded>
    </item>
    <item>
      <title>Basic application with Silverlight for Windows Embedded 6.0 R3</title>
      <link>https://docs.microsoft.com/archive/blogs/brettrobinson/basic-application-with-silverlight-for-windows-embedded-6-0-r3</link>
      <pubDate>Wed, 28 Jul 2010 13:46:17 GMT</pubDate>
      <dc:creator><![CDATA[Brett Robinson]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/brettrobinson/2010/07/28/basic-application-with-silverlight-for-windows-embedded-6-0-r3/</guid>
      <description><![CDATA[I installed CE 6.0 R3 on my laptop when it was initially released and had created an application...]]></description>
      <content:encoded><![CDATA[<p>I installed CE 6.0 R3 on my laptop when it was initially released and had created an application that uses the new SWE for 6.0 R3 API.&nbsp; I have seen a few questions about creating applications, so I figured I would post a small application that I created.</p>
<p>This is <strong>not </strong>a shipping application and was created to show some basic fundamentals of SWE.&nbsp; I have created a custom user control within an application, so very basic.</p>
<p><span lang="EN" style="mso-ansi-language: EN;"><o:p>Download here: <a href="https://brob.members.winisp.net/BrettTestApp.zip" title="Brett Test App">BrettTestApp</a></o:p></span></p>
<p><span lang="EN" style="mso-ansi-language: EN;"><o:p><span lang="EN" style="font-family: 'Arial', 'sans-serif'; font-size: 7.5pt; mso-ansi-language: EN;">Use of included code sample is subject to the terms specified at </span><span lang="EN" style="mso-ansi-language: EN;"><a target="_blank" href="https://www.microsoft.com/info/cpyright.htm"><span style="font-family: 'Arial', 'sans-serif'; font-size: 7.5pt;"><span style="color: #0000cc;">https://www.microsoft.com/info/cpyright.htm</span></span></a></span></o:p></span></p>]]></content:encoded>
    </item>
    <item>
      <title>Silverlight for Windows Embedded Team Blog is live</title>
      <link>https://docs.microsoft.com/archive/blogs/brettrobinson/silverlight-for-windows-embedded-team-blog-is-live</link>
      <pubDate>Wed, 14 Jul 2010 09:45:04 GMT</pubDate>
      <dc:creator><![CDATA[Brett Robinson]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/brettrobinson/2010/07/14/silverlight-for-windows-embedded-team-blog-is-live/</guid>
      <description><![CDATA[We have just released Windows Compact 7 CTP which includes the latest release of Silverlight for...]]></description>
      <content:encoded><![CDATA[<p>We have just released Windows Compact 7 CTP which includes the latest release of Silverlight for Windows Embedded.&nbsp; Because of this, we have decided to also create a new blog that will focus on Silverlight for Windows Embedded topics, tips and tricks and how-tos.&nbsp; There should be some great posts on the way so please subscribe to the feed and feel free to comment and ask questions, that's what the blog is there for.&nbsp; Blog is located here: <a href="https://blogs.msdn.com/b/silverlightforwindowsembedded/">https://blogs.msdn.com/b/silverlightforwindowsembedded/</a></p>
<p>&nbsp;</p>]]></content:encoded>
    </item>
    <item>
      <title>Windows Embedded CE6 R3 released including Silverlight for Windows Embedded</title>
      <link>https://docs.microsoft.com/archive/blogs/brettrobinson/windows-embedded-ce6-r3-released-including-silverlight-for-windows-embedded</link>
      <pubDate>Wed, 23 Sep 2009 12:41:00 GMT</pubDate>
      <dc:creator><![CDATA[Brett Robinson]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/brettrobinson/2009/09/23/windows-embedded-ce6-r3-released-including-silverlight-for-windows-embedded/</guid>
      <description><![CDATA[The project I've been working on since my last blog posts has finally been released!&nbsp; There is...]]></description>
      <content:encoded><![CDATA[<P>The project I've been working on since my last blog posts has finally been released!&nbsp; There is some fantastic documentation out on MSDN that can get you familiar with the new Silverlight for Windows Embedded API and how to create applications: <A href="https://msdn.microsoft.com/en-us/library/ee502198.aspx" target=_blank mce_href="https://msdn.microsoft.com/en-us/library/ee502198.aspx">Silverlight for Windows Embedded</A> on MSDN</P>
<P>The first thing you might wonder is how to create an application that uses this new api.&nbsp; There's an MSDN page for that: <A href="https://msdn.microsoft.com/en-us/library/ee503558.aspx">https://msdn.microsoft.com/en-us/library/ee503558.aspx</A>, but I thought I would start out by showing some code that I've used when creating applications.&nbsp; This uses all the functions detailed on MSDN.</P>
<DIV style="FONT-FAMILY: Courier New; BACKGROUND: white; COLOR: black; FONT-SIZE: 10pt"><PRE style="MARGIN: 0px">INT WINAPI WinMain(</PRE><PRE style="MARGIN: 0px">&nbsp;&nbsp;&nbsp; HINSTANCE hInstance, </PRE><PRE style="MARGIN: 0px">&nbsp;&nbsp;&nbsp; HINSTANCE hPrevInstance, </PRE><PRE style="MARGIN: 0px">&nbsp;&nbsp;&nbsp; LPWSTR lpCmdLine, </PRE><PRE style="MARGIN: 0px">&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: blue">int</SPAN> nCmdShow</PRE><PRE style="MARGIN: 0px">&nbsp;&nbsp;&nbsp; )</PRE><PRE style="MARGIN: 0px">{</PRE><PRE style="MARGIN: 0px">&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: blue">int</SPAN>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; exitCode = -1;</PRE><PRE style="MARGIN: 0px">&nbsp;&nbsp;&nbsp; HRESULT&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; hr = S_OK;</PRE><PRE style="MARGIN: 0px">&nbsp;</PRE><PRE style="MARGIN: 0px">&nbsp;&nbsp;&nbsp; XamlRuntimeManager xr;</PRE><PRE style="MARGIN: 0px">&nbsp;</PRE><PRE style="MARGIN: 0px">&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: blue">if</SPAN>(xr.IsInitialized())</PRE><PRE style="MARGIN: 0px">&nbsp;&nbsp;&nbsp; {</PRE><PRE style="MARGIN: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <SPAN style="COLOR: blue">if</SPAN>(SUCCEEDED(DoSomethingHere(lpCmdLine)))</PRE><PRE style="MARGIN: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {</PRE><PRE style="MARGIN: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; exitCode = 0;</PRE><PRE style="MARGIN: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }</PRE><PRE style="MARGIN: 0px">&nbsp;&nbsp;&nbsp; }</PRE><PRE style="MARGIN: 0px">&nbsp;</PRE><PRE style="MARGIN: 0px">&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: blue">return</SPAN> exitCode;</PRE><PRE style="MARGIN: 0px">}</PRE><PRE style="MARGIN: 0px">&nbsp;</PRE></DIV>
<P>The main thing to notice here is the XamlRuntimeManager, this does all the initilization for you.&nbsp; Lets take a look at what that class does.</P>
<DIV style="FONT-FAMILY: Courier New; BACKGROUND: white; COLOR: black; FONT-SIZE: 10pt"><PRE style="MARGIN: 0px"><SPAN style="COLOR: green">//this class will initialize and uninitialize XamlRuntime</SPAN></PRE><PRE style="MARGIN: 0px"><SPAN style="COLOR: green">//</SPAN></PRE><PRE style="MARGIN: 0px"><SPAN style="COLOR: blue">class</SPAN> XamlRuntimeManager</PRE><PRE style="MARGIN: 0px">{</PRE><PRE style="MARGIN: 0px"><SPAN style="COLOR: blue">private</SPAN>:</PRE><PRE style="MARGIN: 0px">&nbsp;&nbsp;&nbsp; BOOL m_IsInitialized;</PRE><PRE style="MARGIN: 0px">&nbsp;</PRE><PRE style="MARGIN: 0px"><SPAN style="COLOR: blue">public</SPAN>:</PRE><PRE style="MARGIN: 0px">&nbsp;&nbsp;&nbsp; XamlRuntimeManager()</PRE><PRE style="MARGIN: 0px">&nbsp;&nbsp;&nbsp; {</PRE><PRE style="MARGIN: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; m_IsInitialized = XamlRuntimeInitialize();</PRE><PRE style="MARGIN: 0px">&nbsp;&nbsp;&nbsp; }</PRE><PRE style="MARGIN: 0px">&nbsp;</PRE><PRE style="MARGIN: 0px">&nbsp;&nbsp;&nbsp; ~XamlRuntimeManager()</PRE><PRE style="MARGIN: 0px">&nbsp;&nbsp;&nbsp; {</PRE><PRE style="MARGIN: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <SPAN style="COLOR: blue">if</SPAN>(m_IsInitialized)</PRE><PRE style="MARGIN: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {</PRE><PRE style="MARGIN: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; XamlRuntimeUninitialize();</PRE><PRE style="MARGIN: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }</PRE><PRE style="MARGIN: 0px">&nbsp;&nbsp;&nbsp; }</PRE><PRE style="MARGIN: 0px">&nbsp;</PRE><PRE style="MARGIN: 0px">&nbsp;&nbsp;&nbsp; BOOL IsInitialized() { <SPAN style="COLOR: blue">return</SPAN> m_IsInitialized; }</PRE><PRE style="MARGIN: 0px">&nbsp;</PRE><PRE style="MARGIN: 0px">};</PRE><PRE style="MARGIN: 0px">&nbsp;</PRE></DIV>If you want to see this code in action it is in&nbsp;one of the sample applications that has shipped with R3, <A href="https://msdn.microsoft.com/en-us/library/ee504084.aspx" target=_blank mce_href="https://msdn.microsoft.com/en-us/library/ee504084.aspx">XamlPerf</A>.]]></content:encoded>
    </item>
    <item>
      <title>Sharepoint : page level permissions</title>
      <link>https://docs.microsoft.com/archive/blogs/brettrobinson/sharepoint-page-level-permissions</link>
      <pubDate>Fri, 24 Apr 2009 18:52:00 GMT</pubDate>
      <dc:creator><![CDATA[Brett Robinson]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/brettrobinson/2009/04/24/sharepoint-page-level-permissions/</guid>
      <description><![CDATA[Thought I would share out this quick tip on how to define page level permissions on a sharepoint...]]></description>
      <content:encoded><![CDATA[<P>Thought I would share out this quick tip on how to define page level permissions on a sharepoint wiki site.&nbsp; If you go to the Pages view where you see all the pages, you can click on the drop down and click "Manage Permissions".&nbsp; Then you can add/remove users and groups as needed.</P>]]></content:encoded>
    </item>
    <item>
      <title>Microsoft Social Bookmarking</title>
      <link>https://docs.microsoft.com/archive/blogs/brettrobinson/microsoft-social-bookmarking</link>
      <pubDate>Wed, 28 May 2008 00:55:00 GMT</pubDate>
      <dc:creator><![CDATA[Brett Robinson]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/brettrobinson/2008/05/28/microsoft-social-bookmarking/</guid>
      <description><![CDATA[The team I used to work on (and my last contributions there) just launched today.&nbsp; It is...]]></description>
      <content:encoded><![CDATA[<P>The team I used to work on (and my last contributions there) just launched today.&nbsp; It is Microsoft's social bookmarking application.&nbsp; </P>
<P>Check it out: <A href="https://social.msdn.microsoft.com/bookmarks/" mce_href="https://social.msdn.microsoft.com/bookmarks/">https://social.msdn.microsoft.com/bookmarks/</A></P>]]></content:encoded>
    </item>
    <item>
      <title>Goodbye managed, hello again native</title>
      <link>https://docs.microsoft.com/archive/blogs/brettrobinson/goodbye-managed-hello-again-native</link>
      <pubDate>Thu, 15 May 2008 18:26:00 GMT</pubDate>
      <dc:creator><![CDATA[Brett Robinson]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/brettrobinson/2008/05/15/goodbye-managed-hello-again-native/</guid>
      <description><![CDATA[Well, I've moved teams to the Windows Embedded team, so the content of my blog will most likely...]]></description>
      <content:encoded><![CDATA[Well, I've moved teams to the Windows Embedded team, so the content of my blog will most likely change.&nbsp; Stay tuned!]]></content:encoded>
    </item>
    <item>
      <title>Override javascript method in Microsoft Ajax Library</title>
      <link>https://docs.microsoft.com/archive/blogs/brettrobinson/override-javascript-method-in-microsoft-ajax-library</link>
      <pubDate>Thu, 28 Feb 2008 15:40:00 GMT</pubDate>
      <dc:creator><![CDATA[Brett Robinson]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/brettrobinson/2008/02/28/override-javascript-method-in-microsoft-ajax-library/</guid>
      <description><![CDATA[If you would like to override a method in javascript that uses the Microsoft Ajax Library (such as...]]></description>
      <content:encoded><![CDATA[<P>If you would like to override a method in javascript that uses the Microsoft Ajax Library (such as the control toolkit), you can do the following (with the&nbsp;control toolkit as the base which we are overriding):</P>
<P mce_keep="true">Type.registerNamespace('AjaxControlToolkit');</P>
<P>AjaxControlToolkit.YourClassName= function(element)<BR>{<BR>&nbsp;&nbsp; AjaxControlToolkit.YourClassname.initializeBase(this,[element]);<BR>&nbsp; //initialize any variables here<BR>}<BR>AjaxControlToolkit.YourClassName.prototype = <BR>{<BR>_setText: function(item) //this is the function we're overriding<BR>{ <BR>this._callMyNewFunction('hello there');&nbsp; // we're sending an alert instead of the normal behavior<BR>},<BR>_callMyNewFunction: function(alertMessage) // my new method<BR>{<BR>alert(alertMessage);<BR>} </P>
<P>AjaxControlToolkit.YourClassName.inheritsFrom(AjaxControlToolkit.AutoCompleteBehavior);</P>
<P>AjaxControlToolkit.YourClassName.registerClass('AjaxControlToolkit.YourClassName', AjaxControlToolkit.AutoCompleteBehavior);&nbsp; // second parameter is the class you're "inheriting" from</P>
<P>This type of behavior can be applied to any class&nbsp;that uses&nbsp;the Microsoft Ajax Library and is very useful when you need some base behavior for a control and also&nbsp;specific behavior for a particular implemenation.</P>]]></content:encoded>
    </item>
    <item>
      <title>New release of MSDN/TechNet Search, Profile and Forums</title>
      <link>https://docs.microsoft.com/archive/blogs/brettrobinson/new-release-of-msdntechnet-search-profile-and-forums</link>
      <pubDate>Fri, 15 Feb 2008 12:23:00 GMT</pubDate>
      <dc:creator><![CDATA[Brett Robinson]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/brettrobinson/2008/02/15/new-release-of-msdntechnet-search-profile-and-forums/</guid>
      <description><![CDATA[The team I'm working on just released our latest version of MSDN/TechNet Search, Profile and...]]></description>
      <content:encoded><![CDATA[<P>The team I'm working on just released our latest version of MSDN/TechNet Search, Profile and Forums.</P>
<P>For Search this is the latest release and includes the following new features (<A href="https://search.msdn.microsoft.com/" mce_href="https://search.msdn.microsoft.com/">https://search.msdn.microsoft.com/</A>):</P>
<UL>
<LI>Auto-complete hit highlighting.&nbsp; Now if you search for "writeline" you'll see all words that contain that phrase.&nbsp; The terms&nbsp;are also now&nbsp;ordered by the number of times we see a certain term requested.</LI>
<LI>Stackable refinements: after you search and we identify which topic and/or source contain your search term you can now click on multiple topic and/or source refinements and stack them to narrow your search further.</LI>
<LI>We have increased the number of correct results for a search term with new algorithms, so hopefully you'll find your information even faster!</LI></UL>
<P>Profile (<A href="https://profile.msdn.microsoft.com/en-us">https://profile.msdn.microsoft.com/en-us</A><A href="https://search.msdn.microsoft.com/" mce_href="https://search.msdn.microsoft.com/"></A>):</P>
<UL>
<LI>This is a new application that will drive your profile for things like search, forums and other apps to come.&nbsp; So, if you have a live ID go ahead and sign up here to&nbsp;reserve&nbsp;a display&nbsp;name and upload an avatar!</LI></UL>
<P>Forums (<A href="https://forums.msdn.microsoft.com/en-us/forums" mce_href="https://forums.msdn.microsoft.com/en-us/forums">https://forums.msdn.microsoft.com/en-us/forums</A>): </P>
<UL>
<LI>Sam Jarawan created a tutorial video you can watch here that describes all the features:&nbsp; <A href="https://video.msn.com/video.aspx?mkt=en-us&amp;vid=0f50cc69-28ac-44cd-8277-aae119d5d7cd">https://video.msn.com/video.aspx?mkt=en-us&amp;vid=0f50cc69-28ac-44cd-8277-aae119d5d7cd</A></LI></UL>
<P mce_keep="true">&nbsp;</P>]]></content:encoded>
    </item>
    <item>
      <title>Fill server cache with a large data object and have the browser be responsive by using threads</title>
      <link>https://docs.microsoft.com/archive/blogs/brettrobinson/fill-server-cache-with-a-large-data-object-and-have-the-browser-be-responsive-by-using-threads</link>
      <pubDate>Tue, 27 Nov 2007 16:09:00 GMT</pubDate>
      <dc:creator><![CDATA[Brett Robinson]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/brettrobinson/2007/11/27/fill-server-cache-with-a-large-data-object-and-have-the-browser-be-responsive-by-using-threads/</guid>
      <description><![CDATA[Recently I was working on a problem, and after testing the solution I thought it would make a good...]]></description>
      <content:encoded><![CDATA[<P>Recently I was working on a problem, and after testing the solution I thought it would make a good blog post.&nbsp; Here is what I was trying to solve:&nbsp; </P>
<OL>
<LI>Fill the cache with a large set of data (approx. 1M items).</LI>
<LI>Have the original request to the website&nbsp;fill the cache and&nbsp;not block the browers responsiveness.</LI>
<LI>Any new requests to the website should also not wait for the cache to get filled, <STRONG>and </STRONG>also not make the request to fill the cache also.</LI></OL>
<P>The other thing that you should be aware of is that you should have your control be able to work without data being available that you are trying to cache.&nbsp; So, lets take a look at a solution - I put the call inside of a webmethod, but you can use a normal event to accomplish the same thing.&nbsp; Here is&nbsp;the web page class: <P<!-- {\rtf1\ansi\ansicpg\lang1024\noproof1252\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Courier New;}}{\colortbl;\red0\green0\blue0;\red0\green0\blue255;\red0\green255\blue255;\red0\green255\blue0??;\red255\green0\blue255;\red255\green0\blue0;\red255\green255\blue0;\red255\green255\blue255;??\red0\green0\blue128;\red0\green128\blue128;\red0\green128\blue0;??\red128\green0\blue128;\red128\green0\blue0;\red128\green128\blue0;\red128\green128\blue128;??\red192\green192\blue192;}??\fs20 System.Web.Services;\par System.Collections.Generic;\par System.Threading;\par System.Runtime.Remoting.Messaging;\par using\cf0 System.Web;\par ??\cf2 partial\cf0 class\cf0 _Default\cf0 : System.Web.UI.\cf10 Page\par int\cf0 _isCacheLoaded="0;\par" delegate\cf0 (\cf2 MyParameter); match calling myCacheKey;\par _requestContext;\par protected\cf0 Page_Load(\cf2 object\cf0 sender, EventArgs e)\par \par private\cf0 MyWorkerMethod(\cf2 Parameter1)\par Thread\cf0 .Sleep(120000); sleep for 2 mins (REMOVE THIS IN REAL CODE - TEST ONLY)\par myList="\cf2" &gt;();\par myList.Add(\cf13 ?Brett Robinson?\cf0 );\par myList;\par [\cf10 WebMethod\cf0 ]\par DoSomething(\cf2 MyWebParameter)\par myCacheKey="\cf13" ?myCacheKey?\cf0 need save state of httpcontext because it will get dereferenced in the callback\par _requestContext="\cf10" .Current;\par )\par (\cf10 Interlocked\cf0 .Exchange(\cf2 ref\cf0 _isCacheLoaded, 1)="=" AsyncCallback AsyncCallback(CacheData); point callback="\cf2" custom delegate invoke worker myCustomDelegate="\cf2" new\cf0 (MyWorkerMethod);\par myCustomDelegate.BeginInvoke(MyWebParameter, callback, ); call method\par return\cf0 HttpContext\cf0 .Current.Cache[myCacheKey]="=" &gt;;\par public\cf0 static\cf0 void\cf0 CacheData(IAsyncResult CallbackResult)\par asyncResult="CallbackResult" AsyncResult\cf0 myCustomDelegateAgain="asyncResult.AsyncDelegate" as\cf0 DelegateToCallMethod\cf0 ;\par \cf10 List\cf0 &lt;\cf2 string\cf0 myValues="myCustomDelegateAgain.EndInvoke(CallbackResult);\par" (myValues !="\cf2" null\cf0 &amp;&amp; myValues.Count &gt; 0)\par if\cf0 (!\cf2 double\cf0 .TryParse(ConfigurationManager.AppSettings[\cf13 ?SomeCacheValue?\cf0 ], out\cf0 cacheDuration))\par \{\par cacheDuration="0;\par" \cf11 default to 10\par _requestContext.Cache.Insert(myCacheKey, myValues, \cf2 null\par ??\cf0 , DateTime.Now.AddHours(cacheDuration), Cache.NoSlidingExpiration);\par ?? \}\par ??\}\par ??\par ??} -->
<DIV style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: Courier New">
<P style="MARGIN: 0px"><SPAN style="COLOR: #2b91af">&nbsp;&nbsp;&nbsp;&nbsp;1</SPAN>&nbsp;<SPAN style="COLOR: blue">using</SPAN> System.Web.Services;</P>
<P style="MARGIN: 0px"><SPAN style="COLOR: #2b91af">&nbsp;&nbsp;&nbsp;&nbsp;2</SPAN>&nbsp;<SPAN style="COLOR: blue">using</SPAN> System.Collections.Generic;</P>
<P style="MARGIN: 0px"><SPAN style="COLOR: #2b91af">&nbsp;&nbsp;&nbsp;&nbsp;3</SPAN>&nbsp;<SPAN style="COLOR: blue">using</SPAN> System.Threading;</P>
<P style="MARGIN: 0px"><SPAN style="COLOR: #2b91af">&nbsp;&nbsp;&nbsp;&nbsp;4</SPAN>&nbsp;<SPAN style="COLOR: blue">using</SPAN> System.Runtime.Remoting.Messaging;</P>
<P style="MARGIN: 0px"><SPAN style="COLOR: #2b91af">&nbsp;&nbsp;&nbsp;&nbsp;5</SPAN>&nbsp;<SPAN style="COLOR: blue">using</SPAN> System.Web;</P>
<P style="MARGIN: 0px"><SPAN style="COLOR: #2b91af">&nbsp;&nbsp;&nbsp;&nbsp;6</SPAN>&nbsp;</P>
<P style="MARGIN: 0px"><SPAN style="COLOR: #2b91af">&nbsp;&nbsp;&nbsp;&nbsp;7</SPAN>&nbsp;<SPAN style="COLOR: blue">public</SPAN> <SPAN style="COLOR: blue">partial</SPAN> <SPAN style="COLOR: blue">class</SPAN> <SPAN style="COLOR: teal">_Default</SPAN> : System.Web.UI.<SPAN style="COLOR: teal">Page</SPAN></P>
<P style="MARGIN: 0px"><SPAN style="COLOR: #2b91af">&nbsp;&nbsp;&nbsp;&nbsp;8</SPAN>&nbsp;{</P>
<P style="MARGIN: 0px"><SPAN style="COLOR: #2b91af">&nbsp;&nbsp;&nbsp;&nbsp;9</SPAN>&nbsp;&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: blue">private</SPAN> <SPAN style="COLOR: blue">static</SPAN> <SPAN style="COLOR: blue">int</SPAN> _isCacheLoaded = 0;</P>
<P style="MARGIN: 0px"><SPAN style="COLOR: #2b91af">&nbsp;&nbsp;&nbsp;10</SPAN>&nbsp;&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: blue">private</SPAN> <SPAN style="COLOR: blue">delegate</SPAN> <SPAN style="COLOR: teal">List</SPAN>&lt;<SPAN style="COLOR: blue">string</SPAN>&gt; <SPAN style="COLOR: teal">DelegateToCallMethod</SPAN>(<SPAN style="COLOR: blue">string</SPAN> MyParameter); <SPAN style="COLOR: green">//match the calling method</SPAN></P>
<P style="MARGIN: 0px"><SPAN style="COLOR: #2b91af">&nbsp;&nbsp;&nbsp;11</SPAN>&nbsp;&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: blue">private</SPAN> <SPAN style="COLOR: blue">static</SPAN> <SPAN style="COLOR: blue">string</SPAN> myCacheKey;</P>
<P style="MARGIN: 0px"><SPAN style="COLOR: #2b91af">&nbsp;&nbsp;&nbsp;12</SPAN>&nbsp;&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: blue">private</SPAN> <SPAN style="COLOR: blue">static</SPAN> <SPAN style="COLOR: teal">HttpContext</SPAN> _requestContext;</P>
<P style="MARGIN: 0px"><SPAN style="COLOR: #2b91af">&nbsp;&nbsp;&nbsp;13</SPAN>&nbsp;</P>
<P style="MARGIN: 0px"><SPAN style="COLOR: #2b91af">&nbsp;&nbsp;&nbsp;14</SPAN>&nbsp;&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: blue">protected</SPAN> <SPAN style="COLOR: blue">void</SPAN> Page_Load(<SPAN style="COLOR: blue">object</SPAN> sender, EventArgs e)</P>
<P style="MARGIN: 0px"><SPAN style="COLOR: #2b91af">&nbsp;&nbsp;&nbsp;15</SPAN>&nbsp;&nbsp;&nbsp;&nbsp; {</P>
<P style="MARGIN: 0px"><SPAN style="COLOR: #2b91af">&nbsp;&nbsp;&nbsp;16</SPAN>&nbsp;</P>
<P style="MARGIN: 0px"><SPAN style="COLOR: #2b91af">&nbsp;&nbsp;&nbsp;17</SPAN>&nbsp;&nbsp;&nbsp;&nbsp; }</P>
<P style="MARGIN: 0px"><SPAN style="COLOR: #2b91af">&nbsp;&nbsp;&nbsp;18</SPAN>&nbsp;</P>
<P style="MARGIN: 0px"><SPAN style="COLOR: #2b91af">&nbsp;&nbsp;&nbsp;19</SPAN>&nbsp;&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: blue">private</SPAN> <SPAN style="COLOR: teal">List</SPAN>&lt;<SPAN style="COLOR: blue">string</SPAN>&gt; MyWorkerMethod(<SPAN style="COLOR: blue">string</SPAN> Parameter1)</P>
<P style="MARGIN: 0px"><SPAN style="COLOR: #2b91af">&nbsp;&nbsp;&nbsp;20</SPAN>&nbsp;&nbsp;&nbsp;&nbsp; {</P>
<P style="MARGIN: 0px"><SPAN style="COLOR: #2b91af">&nbsp;&nbsp;&nbsp;21</SPAN>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <SPAN style="COLOR: teal">Thread</SPAN>.Sleep(120000); <SPAN style="COLOR: green">//sleep for 2 mins (REMOVE THIS IN REAL CODE - TEST ONLY)</SPAN></P>
<P style="MARGIN: 0px"><SPAN style="COLOR: #2b91af">&nbsp;&nbsp;&nbsp;22</SPAN>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <SPAN style="COLOR: teal">List</SPAN>&lt;<SPAN style="COLOR: blue">string</SPAN>&gt; myList = <SPAN style="COLOR: blue">new</SPAN> <SPAN style="COLOR: teal">List</SPAN>&lt;<SPAN style="COLOR: blue">string</SPAN>&gt;();</P>
<P style="MARGIN: 0px"><SPAN style="COLOR: #2b91af">&nbsp;&nbsp;&nbsp;23</SPAN>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; myList.Add(<SPAN style="COLOR: maroon">"Brett Robinson"</SPAN>);</P>
<P style="MARGIN: 0px"><SPAN style="COLOR: #2b91af">&nbsp;&nbsp;&nbsp;24</SPAN>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <SPAN style="COLOR: blue">return</SPAN> myList;</P>
<P style="MARGIN: 0px"><SPAN style="COLOR: #2b91af">&nbsp;&nbsp;&nbsp;25</SPAN>&nbsp;&nbsp;&nbsp;&nbsp; }</P>
<P style="MARGIN: 0px"><SPAN style="COLOR: #2b91af">&nbsp;&nbsp;&nbsp;26</SPAN>&nbsp;</P>
<P style="MARGIN: 0px"><SPAN style="COLOR: #2b91af">&nbsp;&nbsp;&nbsp;27</SPAN>&nbsp;&nbsp;&nbsp;&nbsp; [<SPAN style="COLOR: teal">WebMethod</SPAN>]</P>
<P style="MARGIN: 0px"><SPAN style="COLOR: #2b91af">&nbsp;&nbsp;&nbsp;28</SPAN>&nbsp;&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: blue">public</SPAN> <SPAN style="COLOR: blue">static</SPAN> <SPAN style="COLOR: teal">List</SPAN>&lt;<SPAN style="COLOR: blue">string</SPAN>&gt; DoSomething(<SPAN style="COLOR: blue">string</SPAN> MyWebParameter)</P>
<P style="MARGIN: 0px"><SPAN style="COLOR: #2b91af">&nbsp;&nbsp;&nbsp;29</SPAN>&nbsp;&nbsp;&nbsp;&nbsp; {</P>
<P style="MARGIN: 0px"><SPAN style="COLOR: #2b91af">&nbsp;&nbsp;&nbsp;30</SPAN>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; myCacheKey = <SPAN style="COLOR: maroon">"myCacheKey"</SPAN>;</P>
<P style="MARGIN: 0px"><SPAN style="COLOR: #2b91af">&nbsp;&nbsp;&nbsp;31</SPAN>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <SPAN style="COLOR: green">//need to save the state of httpcontext because it will get dereferenced in the callback</SPAN></P>
<P style="MARGIN: 0px"><SPAN style="COLOR: #2b91af">&nbsp;&nbsp;&nbsp;32</SPAN>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; _requestContext = <SPAN style="COLOR: teal">HttpContext</SPAN>.Current;</P>
<P style="MARGIN: 0px"><SPAN style="COLOR: #2b91af">&nbsp;&nbsp;&nbsp;33</SPAN>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <SPAN style="COLOR: blue">if</SPAN> (<SPAN style="COLOR: teal">HttpContext</SPAN>.Current.Cache[myCacheKey] == <SPAN style="COLOR: blue">null</SPAN>)</P>
<P style="MARGIN: 0px"><SPAN style="COLOR: #2b91af">&nbsp;&nbsp;&nbsp;34</SPAN>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {</P>
<P style="MARGIN: 0px"><SPAN style="COLOR: #2b91af">&nbsp;&nbsp;&nbsp;35</SPAN>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <SPAN style="COLOR: blue">if</SPAN> (<SPAN style="COLOR: teal">Interlocked</SPAN>.Exchange(<SPAN style="COLOR: blue">ref</SPAN> _isCacheLoaded, 1) == 0)</P>
<P style="MARGIN: 0px"><SPAN style="COLOR: #2b91af">&nbsp;&nbsp;&nbsp;36</SPAN>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {</P>
<P style="MARGIN: 0px"><SPAN style="COLOR: #2b91af">&nbsp;&nbsp;&nbsp;37</SPAN>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; AsyncCallback callback = <SPAN style="COLOR: blue">new</SPAN> AsyncCallback(CacheData);&nbsp; <SPAN style="COLOR: green">//point to callback method</SPAN></P>
<P style="MARGIN: 0px"><SPAN style="COLOR: #2b91af">&nbsp;&nbsp;&nbsp;38</SPAN>&nbsp;</P>
<P style="MARGIN: 0px"><SPAN style="COLOR: #2b91af">&nbsp;&nbsp;&nbsp;39</SPAN>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <SPAN style="COLOR: green">//custom delegate to invoke worker method</SPAN></P>
<P style="MARGIN: 0px"><SPAN style="COLOR: #2b91af">&nbsp;&nbsp;&nbsp;40</SPAN>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <SPAN style="COLOR: teal">DelegateToCallMethod</SPAN> myCustomDelegate = <SPAN style="COLOR: blue">new</SPAN> <SPAN style="COLOR: teal">DelegateToCallMethod</SPAN>(MyWorkerMethod);</P>
<P style="MARGIN: 0px"><SPAN style="COLOR: #2b91af">&nbsp;&nbsp;&nbsp;41</SPAN>&nbsp;</P>
<P style="MARGIN: 0px"><SPAN style="COLOR: #2b91af">&nbsp;&nbsp;&nbsp;42</SPAN>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; myCustomDelegate.BeginInvoke(MyWebParameter, callback, <SPAN style="COLOR: blue">null</SPAN>); <SPAN style="COLOR: green">//call method</SPAN></P>
<P style="MARGIN: 0px"><SPAN style="COLOR: #2b91af">&nbsp;&nbsp;&nbsp;43</SPAN>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }</P>
<P style="MARGIN: 0px"><SPAN style="COLOR: #2b91af">&nbsp;&nbsp;&nbsp;44</SPAN>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }</P>
<P style="MARGIN: 0px"><SPAN style="COLOR: #2b91af">&nbsp;&nbsp;&nbsp;45</SPAN>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <SPAN style="COLOR: blue">return</SPAN> <SPAN style="COLOR: teal">HttpContext</SPAN>.Current.Cache[myCacheKey] <SPAN style="COLOR: blue">as</SPAN> <SPAN style="COLOR: teal">List</SPAN>&lt;<SPAN style="COLOR: blue">string</SPAN>&gt;;</P>
<P style="MARGIN: 0px"><SPAN style="COLOR: #2b91af">&nbsp;&nbsp;&nbsp;46</SPAN>&nbsp;&nbsp;&nbsp;&nbsp; }</P>
<P style="MARGIN: 0px"><SPAN style="COLOR: #2b91af">&nbsp;&nbsp;&nbsp;47</SPAN>&nbsp;</P>
<P style="MARGIN: 0px"><SPAN style="COLOR: #2b91af">&nbsp;&nbsp;&nbsp;48</SPAN>&nbsp;&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: blue">public</SPAN> <SPAN style="COLOR: blue">static</SPAN> <SPAN style="COLOR: blue">void</SPAN> CacheData(IAsyncResult CallbackResult)</P>
<P style="MARGIN: 0px"><SPAN style="COLOR: #2b91af">&nbsp;&nbsp;&nbsp;49</SPAN>&nbsp;&nbsp;&nbsp;&nbsp; {</P>
<P style="MARGIN: 0px"><SPAN style="COLOR: #2b91af">&nbsp;&nbsp;&nbsp;50</SPAN>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <SPAN style="COLOR: teal">AsyncResult</SPAN> asyncResult = CallbackResult <SPAN style="COLOR: blue">as</SPAN> <SPAN style="COLOR: teal">AsyncResult</SPAN>;</P>
<P style="MARGIN: 0px"><SPAN style="COLOR: #2b91af">&nbsp;&nbsp;&nbsp;51</SPAN>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <SPAN style="COLOR: teal">DelegateToCallMethod</SPAN> myCustomDelegateAgain = asyncResult.AsyncDelegate <SPAN style="COLOR: blue">as</SPAN> <SPAN style="COLOR: teal">DelegateToCallMethod</SPAN>;</P>
<P style="MARGIN: 0px"><SPAN style="COLOR: #2b91af">&nbsp;&nbsp;&nbsp;52</SPAN>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <SPAN style="COLOR: teal">List</SPAN>&lt;<SPAN style="COLOR: blue">string</SPAN>&gt; myValues = myCustomDelegateAgain.EndInvoke(CallbackResult);</P>
<P style="MARGIN: 0px"><SPAN style="COLOR: #2b91af">&nbsp;&nbsp;&nbsp;53</SPAN>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <SPAN style="COLOR: blue">if</SPAN> (myValues != <SPAN style="COLOR: blue">null</SPAN> &amp;&amp; myValues.Count &gt; 0)</P>
<P style="MARGIN: 0px"><SPAN style="COLOR: #2b91af">&nbsp;&nbsp;&nbsp;54</SPAN>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {</P>
<P style="MARGIN: 0px"><SPAN style="COLOR: #2b91af">&nbsp;&nbsp;&nbsp;55</SPAN>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <SPAN style="COLOR: blue">double</SPAN> cacheDuration = 0;</P>
<P style="MARGIN: 0px"><SPAN style="COLOR: #2b91af">&nbsp;&nbsp;&nbsp;56</SPAN>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <SPAN style="COLOR: blue">if</SPAN> (!<SPAN style="COLOR: blue">double</SPAN>.TryParse(ConfigurationManager.AppSettings[<SPAN style="COLOR: maroon">"SomeCacheValue"</SPAN>], <SPAN style="COLOR: blue">out</SPAN> cacheDuration))</P>
<P style="MARGIN: 0px"><SPAN style="COLOR: #2b91af">&nbsp;&nbsp;&nbsp;57</SPAN>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {</P>
<P style="MARGIN: 0px"><SPAN style="COLOR: #2b91af">&nbsp;&nbsp;&nbsp;58</SPAN>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; cacheDuration = 10; <SPAN style="COLOR: green">//default to 10</SPAN></P>
<P style="MARGIN: 0px"><SPAN style="COLOR: #2b91af">&nbsp;&nbsp;&nbsp;59</SPAN>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }</P>
<P style="MARGIN: 0px"><SPAN style="COLOR: #2b91af">&nbsp;&nbsp;&nbsp;60</SPAN>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; _requestContext.Cache.Insert(myCacheKey, myValues, <SPAN style="COLOR: blue">null</SPAN></P>
<P style="MARGIN: 0px"><SPAN style="COLOR: #2b91af">&nbsp;&nbsp;&nbsp;61</SPAN>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; , DateTime.Now.AddHours(cacheDuration), Cache.NoSlidingExpiration);</P>
<P style="MARGIN: 0px"><SPAN style="COLOR: #2b91af">&nbsp;&nbsp;&nbsp;62</SPAN>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }</P>
<P style="MARGIN: 0px">&nbsp;&nbsp;&nbsp;<FONT color=#2b91af>63</FONT>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;_isCacheLoaded = 0;</P>
<P style="MARGIN: 0px"><SPAN style="COLOR: #2b91af">&nbsp;&nbsp;&nbsp;64</SPAN>&nbsp;&nbsp;&nbsp;&nbsp; }</P>
<P style="MARGIN: 0px"><SPAN style="COLOR: #2b91af">&nbsp;&nbsp;&nbsp;65</SPAN>&nbsp;}</P>
<P style="MARGIN: 0px"><SPAN style="COLOR: #2b91af">&nbsp;&nbsp;&nbsp;66</SPAN>&nbsp;</P></DIV>
<P>Remember that threads are overhead, and you should only use them when they are appropriate.&nbsp; Also, blocking is bad, so make sure that you never block unless completely necessary.</P>
<P>Hope this helps!&nbsp; Enjoy.</P>]]></content:encoded>
    </item>
  </channel>
</rss>