<?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>This is not the 9 o'clock news...</title>
    <atom:link
      href="https://docs.microsoft.com/archive/blogs/thelever/feed.xml"
      rel="self"
      type="application/rss+xml" />
    <link>https://docs.microsoft.com/archive/blogs/thelever/feed.xml</link>
    <description />
    <lastBuildDate>Wed, 17 Apr 2019 04:08:16 GMT</lastBuildDate>
    <language>en-US</language>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>1</sy:updateFrequency>
    <item>
      <title>Getting 403 in Azure Local Development Environment</title>
      <link>https://docs.microsoft.com/archive/blogs/thelever/getting-403-in-azure-local-development-environment</link>
      <pubDate>Fri, 05 Jul 2013 09:21:08 GMT</pubDate>
      <dc:creator><![CDATA[Boaz Lev - MSFT]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/thelever/2013/07/05/getting-403-in-azure-local-development-environment/</guid>
      <description><![CDATA[Note: In searching for a solution to this problem I faced, I realize that there may be several...]]></description>
      <content:encoded><![CDATA[<p>Note: In searching for a solution to this problem I faced, I realize that there may be several reasons you hit a 403 when you are trying to debug an Azure solution using the local development environment. So, your mileage may definitely vary. Also, note that I don't work on any of the teams developing the great technologies at play here, so there may be easier and more foolproof ways of diagnosing the issues causing this.</p>
<p>I was playing around with an Azure solution consisting of a Web Role serving up some REST endpoints and a Worker Role for background processing. Seemingly without reason, I would all of a sudden get a HTTP error 403 when the browser starts up and tries to navigate to the site. I also got a 404 when I ignored the 403 and tried to invoke one of the exposed endpoints by my Web Role. Several searches online didn't seem to produce anything usable.</p>
<p>After trying out various things for a couple of hours, I decided to go about this in a more methodical manner. Ignoring for now the 404, thinking it could be a consequence of the 403, I decided to try to understand how the 403 came about. Looking at the site in question, I did see that the web.config had an entry allowing directory browsing. So, here was the first hint: If directory browsing is allowed, why was I getting an Access Denied when debugging the solution? Also, could the root cause of the 403 also be the root cause of the 404 returned when trying to invoke the endpoint?</p>
<p>It turns out the answer is yes. What I had inadvertently done was to move the web.config into a different folder in my Visual Studio solution. I didn't even consider that this would also physically move the file on the file system. Obviously, if the file is moved into a different folder (which I did actually notice, but I was too deep in the mud at that point, so I discarded that) IIS will not find it when mapping the request to the file system, and the site will not be configured correctly. So, when I moved the web.config file back to the original location in Visual Studio, things started working flawlessly again.</p>
<p>Morale: Think about what error message is plainly visible. If you are getting an Access Denied&nbsp;(403), there is a good chance that your site has been misconfigured for some simple reason. I hope this post helps others who find themselves in a similar situation.</p>]]></content:encoded>
    </item>
    <item>
      <title>How to make PSI Extensions in Project Server 2010 - Part II</title>
      <link>https://docs.microsoft.com/archive/blogs/thelever/how-to-make-psi-extensions-in-project-server-2010-part-ii</link>
      <pubDate>Fri, 04 Jun 2010 10:25:04 GMT</pubDate>
      <dc:creator><![CDATA[thelever]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/thelever/2010/06/04/how-to-make-psi-extensions-in-project-server-2010-part-ii/</guid>
      <description><![CDATA[In this part, we will actually do something useful with the extension service by filling out the...]]></description>
      <content:encoded><![CDATA[<p class="MsoNormal" style="margin: 0in 0in 10pt;"><span style="font-size: small;"><span style="font-family: Calibri;">In this part, we will actually do something useful with the extension service by filling out the skeleton service that was the result of the last <a href="https://blogs.msdn.com/thelever/archive/2010/05/18/how-to-make-psi-extensions-in-project-server-2010.aspx" title="How to make PSI Extensions in Project Server 2010 - Part I">post</a>. One of the places where the extension services come in handy is when you want to aggregate data before sending it back to the client. In this post, I will develop exactly such a service: My service will, when activated by a client, get the user ID of the caller and with that call the PSIs to get the time sheet list for that particular user. I know this is not too fancy, but I think it illustrates the purpose of my extension service. <o:p></o:p></span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 10pt;"><span style="font-size: small;"><span style="font-family: Calibri;">Knowing that we will call the PSIs ourselves, this leads to the first decision that has to be made: How will we call the back-end from the extension service? There are a couple of options. One option is to generate proxy objects that match the services exposed by the PSIs. Another option is to use the interface assemblies directly and do more of the plumbing yourself. It seems to me that the former method is well described; I will use the latter approach. Personally, I prefer this method for a couple of reasons: I always find the code that is generated off the MEX data is clunky and ugly. And, too much of it is generated &ndash; you typically end up with more files than strictly needed when you go this route. Further, it gives me a sense of being more in control when using the interfaces explicitly and creating the channels myself etc.<o:p></o:p></span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 10pt;"><span style="font-size: small;"><span style="font-family: Calibri;">The next thing that has to be decided is the signature of the operation. The interesting thing to decide is how to handle return types and parameters. Project Server relies heavily on datasets to pass data between client and server. Therefore, it would be a natural approach to use the typed datasets and rely on the assemblies that are installed with Project Server. Another approach is to serialize everything to XML yourself and so be totally platform independent. This is the approach that I have chosen: My extension service is relatively simple, and I don&rsquo;t want the hassle of assemblies that have to be deployed. So, with that in mind, I can rely on simple types such as a string containing all the data of the retrieved dataset as XML.<o:p></o:p></span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 10pt;"><span style="font-size: small;"><span style="font-family: Calibri;">With the decisions behind us, we can start to write the code. First, we have to change the contract of the extension service. Instead of having a method called <b style="mso-bidi-font-weight: normal;">EchoHello</b>, let&rsquo;s call it something more appropriate: <b style="mso-bidi-font-weight: normal;">ReadTimesheetListForCurrentUser</b> makes the entire contract definition look like this: <o:p></o:p></span></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; color: blue; font-size: 8pt; mso-no-proof: yes;">namespace</span><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"> Project.Server.Extensions<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;">{<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp; </span>[<span style="color: #2b91af;">ServiceContract</span>]<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp; </span><span style="color: blue;">internal</span> <span style="color: blue;">interface</span> <span style="color: #2b91af;">IExtensionPSIService<o:p></o:p></span></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp; </span>{<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>[<span style="color: #2b91af;">OperationContract</span>]<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">string</span> ReadTimesheetListForCurrentUser();<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp; </span>}<o:p></o:p></span></p>
<p class="MsoNormal" style="margin: 0in 0in 10pt;"><span style="line-height: 115%; font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;">}<o:p></o:p></span></p>
<p class="MsoNormal" style="margin: 0in 0in 10pt;"><span style="font-size: small;"><span style="font-family: Calibri;">Also change the actual implementation so that it looks like this:<o:p></o:p></span></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; color: gray; font-size: 8pt; mso-no-proof: yes;">// Other using declarations omitted for brevity<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; color: blue; font-size: 8pt; mso-no-proof: yes;">using</span><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"> Microsoft.Office.Project.Server.Interfaces;<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; color: blue; font-size: 8pt; mso-no-proof: yes;">using</span><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"> Microsoft.Office.Project.Server.Schema;<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; color: blue; font-size: 8pt; mso-no-proof: yes;">namespace</span><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"> Project.Server.Extensions<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;">{<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp; </span>[<span style="color: #2b91af;">AspNetCompatibilityRequirements</span>(RequirementsMode = <span style="color: #2b91af;">AspNetCompatibilityRequirementsMode</span>.Allowed)]<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp; </span><span style="color: blue;">internal</span> <span style="color: blue;">class</span> <span style="color: #2b91af;">ExtensionPSIService</span> : <span style="color: #2b91af;">IExtensionPSIService<o:p></o:p></span></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp; </span>{<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">private</span> <span style="color: blue;">static</span> <span style="color: blue;">string</span> serverUri;<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">private</span> <span style="color: blue;">static</span> <span style="color: #2b91af;">BasicHttpBinding</span> binding;<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; color: blue; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>#region</span><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"> IExtensionPSIService Members<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>[<span style="color: #2b91af;">OperationBehavior</span>(Impersonation = <span style="color: #2b91af;">ImpersonationOption</span>.Required)]<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">public</span> <span style="color: blue;">string</span> ReadTimesheetListForCurrentUser()<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="mso-spacerun: yes;">&nbsp;</span>{<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">try<o:p></o:p></span></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>{<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: gray;">// Get the user ID of the calling user<o:p></o:p></span></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">var</span> resourceChannel = CreateClientChannel&lt;<span style="color: #2b91af;">IResource</span>&gt;();<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: #2b91af;">Guid</span> userUid = resourceChannel.GetCurrentUserUid();<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>((<span style="color: #2b91af;">IClientChannel</span>)resourceChannel).Close();<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>((<span style="color: #2b91af;">IClientChannel</span>)resourceChannel).Dispose();<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: gray;">// Get the time sheet for the user<o:p></o:p></span></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">var</span> timeSheetChannel = CreateClientChannel&lt;<span style="color: #2b91af;">ITimeSheet</span>&gt;();<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">var</span> timeSheetData = timeSheetChannel.ReadTimesheetList(userUid,<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: #2b91af;">DateTime</span>.Now.AddDays(-<span style="color: navy;">7</span>),<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: #2b91af;">DateTime</span>.Now,<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: navy;">1</span>);<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>((<span style="color: #2b91af;">IClientChannel</span>)timeSheetChannel).Close();<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>((<span style="color: #2b91af;">IClientChannel</span>)timeSheetChannel).Dispose();<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: gray;">// Get a reader of the data...<o:p></o:p></span></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">var</span> xmlData = timeSheetData.GetXml();<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">return</span> xmlData;<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>}<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">catch</span> (<span style="color: #2b91af;">Exception</span>)<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>{<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">throw</span>;<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>}<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>}<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal" style="margin: 0in 0in 10pt;"><span style="line-height: 115%; font-family: 'Courier New'; color: blue; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>#endregion</span><span style="line-height: 115%; font-size: 8pt;"><span style="font-family: Calibri;"> <o:p></o:p></span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 10pt;"><span style="line-height: 115%; font-size: 8pt;"><span style="font-family: Calibri;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>&hellip;<o:p></o:p></span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 10pt;"><span style="font-size: small;"><span style="font-family: Calibri;">Let&rsquo;s go through the code in greater detail:<o:p></o:p></span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 10pt;"><span style="font-size: small;"><span style="font-family: Calibri;">I start by declaring a couple of variables that I will need during operation: <b style="mso-bidi-font-weight: normal;">serverUri</b> is going to hold the Uri to the Project Server front-end routing service and <b style="mso-bidi-font-weight: normal;">binding</b> is the binding we use to connect to the Project Server front-end service.<o:p></o:p></span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 10pt;"><span style="font-size: small;"><span style="font-family: Calibri;">I have adorned the <b style="mso-bidi-font-weight: normal;"><span style="mso-no-proof: yes; mso-bidi-font-family: 'Courier New';">ReadTimesheetListForCurrentUser</span></b> method with an operation behavior that specifies that impersonation is required for this method. This is because I want to retain the identity of the caller of my extension service when I call Project Server. The method includes the actual calls that are to be aggregated. First I call the Resource business object to get the unique ID of the calling user, and then I call the Timesheet business object to retrieve the timesheet list for the calling user. You may want to allow the caller to specify the range of the timesheet list in more flexible way in your production code.<o:p></o:p></span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 10pt;"><span style="font-family: Calibri;"><span style="font-size: small;">Finally, after retrieving the dataset that contains the timesheet list, I read the XML representation of that dataset and return it to the caller. To make this work, I use a few helper functions which I will go through now. First, I use <b style="mso-bidi-font-weight: normal;"><span style="mso-no-proof: yes; mso-bidi-font-family: 'Courier New';">CreateClientChannel&lt;<span style="color: #2b91af;">T</span>&gt;</span></b></span><span style="line-height: 115%; font-size: 8pt; mso-no-proof: yes; mso-bidi-font-family: 'Courier New';"> </span><span style="font-size: small;"><span style="mso-no-proof: yes; mso-bidi-font-family: 'Courier New';">to </span>ease the work associated with getting a channel to the targeted service. <b style="mso-bidi-font-weight: normal;"><span style="color: #2b91af; mso-no-proof: yes; mso-bidi-font-family: 'Courier New';">T</span></b> is the &ldquo;shape&rdquo; of the channel, or the interface type you are using. The helper function looks like this:<o:p></o:p></span></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; color: blue; font-size: 8pt; mso-no-proof: yes;">private</span><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"> <span style="color: blue;">static</span> TChannel CreateClientChannel&lt;TChannel&gt;()<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;">{<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; color: blue; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp; </span>var</span><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"> channelFactory = <span style="color: blue;">new</span> <span style="color: #2b91af;">ChannelFactory</span>&lt;TChannel&gt;(<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp; </span><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;</span>Binding,<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">new</span> <span style="color: #2b91af;">EndpointAddress</span>(ServerUri));<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp; </span>channelFactory.Credentials.Windows.AllowedImpersonationLevel = <span style="color: #2b91af;">TokenImpersonationLevel</span>.Impersonation;<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp; </span><span style="color: blue;">return</span> channelFactory.CreateChannel();<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;">}<o:p></o:p></span></p>
<p class="MsoNormal" style="margin: 0in 0in 10pt;"><o:p><span style="font-family: Calibri; font-size: small;">&nbsp;</span></o:p></p>
<p class="MsoNormal" style="margin: 0in 0in 10pt;"><span style="font-size: small;"><span style="font-family: Calibri;">The helper internally makes use of two properties, <b style="mso-bidi-font-weight: normal;"><span style="mso-no-proof: yes; mso-bidi-font-family: 'Courier New';">Binding</span></b> and <b style="mso-bidi-font-weight: normal;"><span style="mso-no-proof: yes; mso-bidi-font-family: 'Courier New';">ServerUri</span></b>, which are just the variables explained above exposed as properties with a lazy initialization pattern on top of them. Note that in production code, you&rsquo;ll probably want to cache the <b style="mso-bidi-font-weight: normal;">ChannelFactory&lt;T&gt;</b> because that is the most expensive object to create. The methods used to lazily initialize the two <b style="mso-bidi-font-weight: normal;">Binding</b> and <b style="mso-bidi-font-weight: normal;">ServerUri</b> properties are written like this: <o:p></o:p></span></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; color: blue; font-size: 8pt; mso-no-proof: yes;">private</span><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"> <span style="color: blue;">static</span> <span style="color: blue;">string</span> GetServerUri(<span style="color: #2b91af;">HttpContext</span> context)<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;">{<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp; </span><span style="color: blue;">var</span> schemeAndServer = context.Request.Url.GetComponents(<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp; </span><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;</span><span style="color: #2b91af;">UriComponents</span>.SchemeAndServer,<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: #2b91af;">UriFormat</span>.SafeUnescaped);<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; color: blue; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp; </span>var</span><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"> requestUrl = context.Request.Url;<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp; </span><span style="color: blue;">int</span> portNo = <span style="color: navy;">80</span>;<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp; </span><span style="color: blue;">var</span> portString = requestUrl.GetComponents(<span style="color: #2b91af;">UriComponents</span>.Port, <span style="color: #2b91af;">UriFormat</span>.SafeUnescaped);<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp; </span><span style="color: blue;">if</span> (!<span style="color: blue;">string</span>.IsNullOrEmpty(portString))<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp; </span>{<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp; </span><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;</span>portNo = <span style="color: blue;">int</span>.Parse(portString);<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp; </span>}<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp; </span><span style="color: blue;">var</span> uriBuilder = <span style="color: blue;">new</span> <span style="color: #2b91af;">UriBuilder</span>(<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp; </span><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;</span>requestUrl.GetComponents(<span style="color: #2b91af;">UriComponents</span>.Scheme, <span style="color: #2b91af;">UriFormat</span>.SafeUnescaped),<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>requestUrl.GetComponents(<span style="color: #2b91af;">UriComponents</span>.Host, <span style="color: #2b91af;">UriFormat</span>.SafeUnescaped),<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>portNo,<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>context.Request.RawUrl.Replace(<span style="color: red;">"Service.svc"</span>, <span style="color: red;">"ProjectServer.svc"</span>));<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp; </span><span style="color: blue;">return</span> uriBuilder.Uri.ToString();<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;">}<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; color: blue; font-size: 8pt; mso-no-proof: yes;">private</span><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"> <span style="color: blue;">static</span> <span style="color: #2b91af;">BasicHttpBinding</span> GetServerBinding()<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;">{<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; color: blue; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp; </span>var</span><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"> serverBinding = <span style="color: blue;">new</span> <span style="color: #2b91af;">BasicHttpBinding</span>(<span style="color: #2b91af;">BasicHttpSecurityMode</span>.TransportCredentialOnly);<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp; </span>serverBinding = <span style="color: blue;">new</span> <span style="color: #2b91af;">BasicHttpBinding</span>(<span style="color: #2b91af;">BasicHttpSecurityMode</span>.TransportCredentialOnly);<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp; </span>serverBinding.AllowCookies = <span style="color: blue;">true</span>;<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp; </span>serverBinding.MessageEncoding = <span style="color: #2b91af;">WSMessageEncoding</span>.Text;<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp; </span>serverBinding.TransferMode = <span style="color: #2b91af;">TransferMode</span>.StreamedResponse;<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp; </span>serverBinding.Security.Transport.ClientCredentialType = <span style="color: #2b91af;">HttpClientCredentialType</span>.Ntlm;<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp; </span>serverBinding.Security.Transport.ProxyCredentialType = <span style="color: #2b91af;">HttpProxyCredentialType</span>.Ntlm;<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp; </span>serverBinding.Security.Transport.Realm = <span style="color: red;">"foo.acme.com"</span>;<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp; </span>serverBinding.MaxBufferSize = <span style="color: blue;">int</span>.MaxValue;<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp; </span>serverBinding.MaxReceivedMessageSize = <span style="color: blue;">long</span>.MaxValue;<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp; </span>serverBinding.ReaderQuotas.MaxArrayLength = <span style="color: navy;">50000000</span>;<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp; </span>serverBinding.ReaderQuotas.MaxNameTableCharCount = <span style="color: navy;">5000000</span>;<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp; </span>serverBinding.ReaderQuotas.MaxStringContentLength = <span style="color: navy;">640000</span>;<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp; </span>serverBinding.ReceiveTimeout = <span style="color: #2b91af;">TimeSpan</span>.FromHours(<span style="color: navy;">1</span>);<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp; </span>serverBinding.OpenTimeout = <span style="color: #2b91af;">TimeSpan</span>.FromHours(<span style="color: navy;">1</span>);<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp; </span>serverBinding.SendTimeout = <span style="color: #2b91af;">TimeSpan</span>.FromHours(<span style="color: navy;">1</span>);<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp; </span><span style="color: blue;">return</span> serverBinding;<o:p></o:p></span></p>
<p class="MsoNormal" style="margin: 0in 0in 10pt;"><span style="line-height: 115%; font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;">}</span><span style="line-height: 115%; font-family: 'Courier New'; font-size: 10pt; mso-no-proof: yes;"><o:p></o:p></span></p>
<p class="MsoNormal" style="margin: 0in 0in 10pt;"><span style="font-size: small;"><span style="font-family: Calibri;">As always, the code is provided as-is: not tuned for performance nor made robust to handle failures. In production code, you&rsquo;ll probably want to use different sizes for the maximum buffer size, etc. Also, make sure your security parameters match what your setup has.<o:p></o:p></span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 10pt;"><span style="font-size: small;"><span style="font-family: Calibri;">Now, at the end of the post, let&rsquo;s just throw together a client that can call our extension service. It turns out that this task is extremely simple: We have all the parts needed. Start a new console project, and add a reference to <b style="mso-bidi-font-weight: normal;">System.ServiceModel</b>. Copy the declaration of the contract (<b style="mso-bidi-font-weight: normal;"><span style="color: #2b91af; mso-no-proof: yes; mso-bidi-font-family: 'Courier New';">IExtensionPSIService</span></b>) into your client project. This is one of the really cool things about WCF: it does not have to be the same type, as long as the types are wire-compliant. To us, this means that you can have the interface in a totally different assembly as long as the operations and their signatures (and also SOAP namespaces &ndash; a feature that we have not used here) are the same. You&rsquo;ll also need a way to create a binding; for this purpose, you can just copy the code that we have in the extension service. Your client now looks like this:<o:p></o:p></span></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; color: blue; font-size: 8pt; mso-no-proof: yes;">static</span><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"> <span style="color: blue;">void</span> Main(<span style="color: blue;">string</span>[] args)<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;">{<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; color: #2b91af; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp; </span>IExtensionPSIService</span><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"> channel = <span style="color: blue;">null</span>;<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp; </span><span style="color: blue;">var</span> binding = CreateCustomBinding();<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp; </span><span style="color: blue;">try<o:p></o:p></span></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp; </span>{<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp; </span><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;</span><span style="color: blue;">var</span> channelFactory = <span style="color: blue;">new</span> <span style="color: #2b91af;">ChannelFactory</span>&lt;<span style="color: #2b91af;">IExtensionPSIService</span>&gt;(binding);<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>channelFactory.Credentials.Windows.AllowNtlm = <span style="color: blue;">true</span>;<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>channelFactory.Credentials.Windows.AllowedImpersonationLevel = <span style="mso-spacerun: yes;">&nbsp;</span><span style="color: #2b91af;">TokenImpersonationLevel</span>.Impersonation;<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>channel = channelFactory.CreateChannel(<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;</span><span style="color: blue;">new</span> <span style="color: #2b91af;">EndpointAddress</span>(<span style="color: red;">"https://&lt;servername&gt;[:port]/pwa/_vti_bin/PSI/Service.svc"</span>));<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">var</span> result = channel.ReadTimesheetListForCurrentUser();<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: #2b91af;">Console</span>.WriteLine(result);<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp; </span>}<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp; </span><span style="color: blue;">catch</span> (<span style="color: #2b91af;">Exception</span> e)<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp; </span>{<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp; </span><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;</span><span style="color: #2b91af;">Console</span>.WriteLine(e.Message);<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp; </span>}<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp; </span><span style="color: blue;">finally<o:p></o:p></span></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp; </span>{<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp; </span><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;</span>((<span style="color: #2b91af;">IClientChannel</span>)channel).Close();<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>((<span style="color: #2b91af;">IClientChannel</span>)channel).Dispose();<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp; </span>}<o:p></o:p></span></p>
<p class="MsoNormal" style="margin: 0in 0in 10pt;"><span style="line-height: 115%; font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;">}</span><span style="line-height: 115%; font-size: 8pt;"><o:p></o:p></span></p>
<p><span style="line-height: 115%; font-family: 'Calibri', 'sans-serif'; font-size: 11pt; mso-bidi-font-family: 'Times New Roman'; mso-bidi-language: AR-SA; mso-ansi-language: EN-US; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-fareast-language: EN-US; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-theme-font: minor-bidi;"><span>Easy, eh?</span></span> </p>]]></content:encoded>
    </item>
    <item>
      <title>How to make PSI Extensions in Project Server 2010 - Part I</title>
      <link>https://docs.microsoft.com/archive/blogs/thelever/how-to-make-psi-extensions-in-project-server-2010-part-i</link>
      <pubDate>Fri, 04 Jun 2010 10:21:00 GMT</pubDate>
      <dc:creator><![CDATA[thelever]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/thelever/2010/06/04/how-to-make-psi-extensions-in-project-server-2010-part-i/</guid>
      <description><![CDATA[In the SDK that accompanied Project Server 2007, one of the samples explains how to extend the...]]></description>
      <content:encoded><![CDATA[<p><span style="font-family: Calibri; font-size: small;">In the SDK that accompanied Project Server 2007, one of the samples explains how to <a target="_blank" href="https://msdn.microsoft.com/en-us/library/bb428837.aspx" title="Extending the Project Server Interface">extend the Project Server Interface</a> (PSI).</span><span style="font-size: small;"><span style="font-family: Calibri;"> The main point of PSI extensibility is the ability to deploy additional content (in terms of services) that can aggregate PSI methods and enhance Project Server functionality. Further, PSI extensions enable the same addressability and Project Server security as do the built-in PSI methods (PSIs). If you know the URL of the PSIs, you also have the URL of the extension &ndash; there is no other complicated URL to remember.<o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="font-size: small;"><span style="font-family: Calibri;">So, why I am writing this all over again? Well, the answer is that things have changed since the release of Office 2007. I will not go into all details, but two changes stand out: claims authentication and WCF. Over the course of the Microsoft SharePoint Foundation 2010 and Project Server 2010 release, the internal authentication infrastructure was changed to claims. A whole slew of very cool scenarios are now enabled by claims authentication. For Project Server, this means that all back-end services &ndash;the PSIs &ndash; are now placed in an access control list (ACL) <span style="mso-spacerun: yes;">&nbsp;</span>by using claims. Checking the ACL is done by an entity referred to as &ldquo;the gatekeeper&rdquo;. The gatekeeper inspects the set of claims that travels along with the request, and if satisfied the gatekeeper allows the service invocation to occur. If not, the service invocation request is rejected. Secondly, using claims as the authentication mechanism mandates that WCF is the transport infrastructure as it is impossible to associate a claim with a regular ASMX web service call.<o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="font-size: small;"><span style="font-family: Calibri;">The primary change from Project Server 2007 and Project Server 2010 is mandated by the introduction of claims: Since all services on the backend are now ACL&rsquo;ed using a claim (via the gatekeeper), if you were to call a service on the backend directly, you&rsquo;d have to obtain a set of claims describing you the calling entity. This is certainly doable, but not trivial: It requires you to make a call to a suited STS and obtain the produced claim and associate it with the request you are about to make to the backend. So, to make this easier for you, we have changed the way you deploy PSI extensions. In this multi-part post, I will explain how to make a PSI extension service that lives and breathes under Project Server 2010. In this first part, I will get the skeleton service up and running and in the next part, I&rsquo;ll try to actually do something useful with the extension service and also get a client working. Finally, I&rsquo;ll try to illustrate what the changes are between a 2007 extension and a 2010 extension and hopefully give some guidance on what needs to change for a 2007 extension to be migrated to a 2010 extension.<o:p></o:p></span></span></p>
<h2 style="margin: 10pt 0in 0pt;"><span style="font-size: medium;"><span style="color: #4f81bd;"><span style="font-family: Cambria;">PSI Extension Skeleton using Project Server 2010 &ndash; Part I<o:p></o:p></span></span></span></h2>
<p class="MsoNormal"><span style="font-size: small;"><span style="font-family: Calibri;">Because of the changes in the authentication and authorization infrastructure that occurred during the development of Office 2010, PSI extensions now are deployed on the front-end. Since the extension service will be a WCF service, a couple of things (configuration items) have to be accomplished in order for your service to be functional as a WCF service. The mantra to use when developing WCF services is A-B-C, or Address, Binding and Contract. In short, the address designates where the service is reachable, the binding determines transport properties like transport type, message size etc., and the contract defines what a request and a suitable response for the actual service operation looks like.<o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="font-size: small;"><span style="font-family: Calibri;">One of the really cool features of WCF is that many properties of your service are governed by configuration files so that you can focus on writing your business logic without having to worry about the infrastructure that makes it all possible. To that end, we will take care of the address and the binding in the configuration file that governs the front-end. Finding that particular configuration file can be accomplished in several ways &ndash; I have chosen to use PowerShell this time. The following script gets you the exact location of the configuration file we are interested in:<o:p></o:p></span></span></p>
<p class="MsoNormal"><o:p><span style="font-family: Calibri; font-size: small;"></span></o:p>&nbsp;</p>
<p class="MsoNormal"><span style="line-height: 115%; font-family: Courier; font-size: 8pt;"><span style="font-size: x-small;"><span>[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.Web.Administration") &gt; $null <o:p></o:p></span></span></span></p>
<p class="MsoNormal"><span style="line-height: 115%; font-family: Courier; font-size: 8pt;"><span style="font-size: x-small;"><span>$serverManager = New-Object -TypeName Microsoft.Web.Administration.ServerManager<o:p></o:p></span></span></span></p>
<p class="MsoNormal"><span style="line-height: 115%; font-family: Courier; font-size: 8pt;"><span style="font-size: x-small;"><span>$site = $serverManager.Sites["SharePoint - 80"]<o:p></o:p></span></span></span></p>
<p class="MsoNormal"><span style="line-height: 115%; font-family: Courier; font-size: 8pt;"><o:p><span style="font-size: x-small;">&nbsp;</span></o:p></span></p>
<p class="MsoNormal"><span style="line-height: 115%; font-family: Courier; font-size: 8pt;"><span style="font-size: x-small;"><span>foreach($app in $site.Applications)<o:p></o:p></span></span></span></p>
<p class="MsoNormal"><span style="line-height: 115%; font-family: Courier; font-size: 8pt;"><span style="font-size: x-small;"><span>{<o:p></o:p></span></span></span></p>
<p class="MsoNormal"><span style="line-height: 115%; font-family: Courier; font-size: 8pt;"><span style="font-size: x-small;"><span><span style="mso-spacerun: yes;">&nbsp;&nbsp; </span>foreach($vdir in $app.VirtualDirectories)<o:p></o:p></span></span></span></p>
<p class="MsoNormal"><span style="line-height: 115%; font-family: Courier; font-size: 8pt;"><span style="font-size: x-small;"><span><span style="mso-spacerun: yes;">&nbsp;&nbsp; </span>{<o:p></o:p></span></span></span></p>
<p class="MsoNormal"><span style="line-height: 115%; font-family: Courier; font-size: 8pt;"><span style="font-size: x-small;"><span><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>$outputPath = $vdir.PhysicalPath + "\PSI\web.config"<o:p></o:p></span></span></span></p>
<p class="MsoNormal"><span style="line-height: 115%; font-family: Courier; font-size: 8pt;"><span style="font-size: x-small;"><span><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>if([System.IO.File]::Exists($outputPath))<o:p></o:p></span></span></span></p>
<p class="MsoNormal"><span style="line-height: 115%; font-family: Courier; font-size: 8pt;"><span style="font-size: x-small;"><span><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>{<o:p></o:p></span></span></span></p>
<p class="MsoNormal"><span style="line-height: 115%; font-family: Courier; font-size: 8pt;"><span style="font-size: x-small;"><span><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>Write-Host $outputPath<o:p></o:p></span></span></span></p>
<p class="MsoNormal"><span style="line-height: 115%; font-family: Courier; font-size: 8pt;"><span style="font-size: x-small;"><span><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>}<o:p></o:p></span></span></span></p>
<p class="MsoNormal"><span style="line-height: 115%; font-family: Courier; font-size: 8pt;"><span style="font-size: x-small;"><span><span style="mso-spacerun: yes;">&nbsp;&nbsp; </span>}<o:p></o:p></span></span></span></p>
<p class="MsoNormal"><span style="line-height: 115%; font-family: Courier; font-size: 8pt;"><span style="font-size: x-small;"><span>}<o:p></o:p></span></span></span></p>
<p class="MsoNormal"><span style="line-height: 115%; font-family: Courier; font-size: 8pt;"><o:p><span style="font-size: x-small;">&nbsp;</span></o:p></span></p>
<p class="MsoNormal"><span style="line-height: 115%; font-family: Courier; font-size: 8pt;"><span style="font-size: x-small;"><span>$serverManager.Dispose()<o:p></o:p></span></span></span></p>
<p class="MsoNormal"><span style="line-height: 115%; font-family: Courier; font-size: 8pt;"><span style="font-size: x-small;">$serverManager = $null</span> </span><o:p></o:p></p>
<p class="MsoNormal"><span style="font-size: small;"><span style="font-family: Calibri;">If all works out well, the previous script (you may have to run it in a PowerShell<span style="mso-spacerun: yes;">&nbsp; </span>prompt with elevated privileges) should output the path to the configuration file that governs the PWA front-end. Note, you will most likely have to replace the site name (&ldquo;SharePoint &ndash; 80&rdquo; in my case) with what you have called your default SharePoint site.<o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="font-size: small;"><span style="font-family: Calibri;">Now, open the web.config file of the site, and make a few changes to the file. First, you&rsquo;ll need to define what bindings your extension service will be using. Keep in mind that this will have to be compatible with the bindings configured for the SharePoint site that hosts your PWA. For the sake of this example, the binding entries, which go into the &lt;system.serviceModel&gt; section, look like this: <o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="font-family: 'Courier New'; color: blue; font-size: 8pt; mso-no-proof: yes;">&lt;</span><span style="font-family: 'Courier New'; color: #a31515; font-size: 8pt; mso-no-proof: yes;">bindings</span><span style="font-family: 'Courier New'; color: blue; font-size: 8pt; mso-no-proof: yes;">&gt;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: 'Courier New'; color: blue; font-size: 8pt; mso-no-proof: yes;">&nbsp; &lt;</span><span style="font-family: 'Courier New'; color: #a31515; font-size: 8pt; mso-no-proof: yes;">basicHttpBinding</span><span style="font-family: 'Courier New'; color: blue; font-size: 8pt; mso-no-proof: yes;">&gt;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: 'Courier New'; color: blue; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;</span>&lt;</span><span style="font-family: 'Courier New'; color: #a31515; font-size: 8pt; mso-no-proof: yes;">binding</span><span style="font-family: 'Courier New'; color: blue; font-size: 8pt; mso-no-proof: yes;"> </span><span style="font-family: 'Courier New'; color: red; font-size: 8pt; mso-no-proof: yes;">name</span><span style="font-family: 'Courier New'; color: blue; font-size: 8pt; mso-no-proof: yes;">=</span><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;">"<span style="color: blue;">extensionBasicHttpConf</span>"<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: 'Courier New'; color: blue; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><span style="font-family: 'Courier New'; color: red; font-size: 8pt; mso-no-proof: yes;">closeTimeout</span><span style="font-family: 'Courier New'; color: blue; font-size: 8pt; mso-no-proof: yes;">=</span><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;">"<span style="color: blue;">00:01:00</span>"<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: 'Courier New'; color: blue; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><span style="font-family: 'Courier New'; color: red; font-size: 8pt; mso-no-proof: yes;">openTimeout</span><span style="font-family: 'Courier New'; color: blue; font-size: 8pt; mso-no-proof: yes;">=</span><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;">"<span style="color: blue;">00:01:00</span>"<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: 'Courier New'; color: blue; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><span style="font-family: 'Courier New'; color: red; font-size: 8pt; mso-no-proof: yes;">receiveTimeout</span><span style="font-family: 'Courier New'; color: blue; font-size: 8pt; mso-no-proof: yes;">=</span><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;">"<span style="color: blue;">00:10:00</span>"<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: 'Courier New'; color: blue; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><span style="font-family: 'Courier New'; color: red; font-size: 8pt; mso-no-proof: yes;">sendTimeout</span><span style="font-family: 'Courier New'; color: blue; font-size: 8pt; mso-no-proof: yes;">=</span><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;">"<span style="color: blue;">00:01:00</span>"<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: 'Courier New'; color: blue; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><span style="font-family: 'Courier New'; color: red; font-size: 8pt; mso-no-proof: yes;">allowCookies</span><span style="font-family: 'Courier New'; color: blue; font-size: 8pt; mso-no-proof: yes;">=</span><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;">"<span style="color: blue;">true</span>"<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: 'Courier New'; color: blue; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><span style="font-family: 'Courier New'; color: red; font-size: 8pt; mso-no-proof: yes;">maxBufferSize</span><span style="font-family: 'Courier New'; color: blue; font-size: 8pt; mso-no-proof: yes;">=</span><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;">"<span style="color: blue;">4194304</span>"<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: 'Courier New'; color: blue; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><span style="font-family: 'Courier New'; color: red; font-size: 8pt; mso-no-proof: yes;">maxReceivedMessageSize</span><span style="font-family: 'Courier New'; color: blue; font-size: 8pt; mso-no-proof: yes;">=</span><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;">"<span style="color: blue;">500000000</span>"<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: 'Courier New'; color: blue; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><span style="font-family: 'Courier New'; color: red; font-size: 8pt; mso-no-proof: yes;">messageEncoding</span><span style="font-family: 'Courier New'; color: blue; font-size: 8pt; mso-no-proof: yes;">=</span><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;">"<span style="color: blue;">Text</span>"<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: 'Courier New'; color: blue; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><span style="font-family: 'Courier New'; color: red; font-size: 8pt; mso-no-proof: yes;">transferMode</span><span style="font-family: 'Courier New'; color: blue; font-size: 8pt; mso-no-proof: yes;">=</span><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;">"<span style="color: blue;">StreamedResponse</span>"<span style="color: blue;">&gt;<o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="font-family: 'Courier New'; color: blue; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>&lt;</span><span style="font-family: 'Courier New'; color: #a31515; font-size: 8pt; mso-no-proof: yes;">security</span><span style="font-family: 'Courier New'; color: blue; font-size: 8pt; mso-no-proof: yes;"> </span><span style="font-family: 'Courier New'; color: red; font-size: 8pt; mso-no-proof: yes;">mode</span><span style="font-family: 'Courier New'; color: blue; font-size: 8pt; mso-no-proof: yes;">=</span><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;">"<span style="color: blue;">TransportCredentialOnly</span>"<span style="color: blue;">&gt;<o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="font-family: 'Courier New'; color: blue; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>&lt;</span><span style="font-family: 'Courier New'; color: #a31515; font-size: 8pt; mso-no-proof: yes;">transport</span><span style="font-family: 'Courier New'; color: blue; font-size: 8pt; mso-no-proof: yes;"> </span><span style="font-family: 'Courier New'; color: red; font-size: 8pt; mso-no-proof: yes;">clientCredentialType</span><span style="font-family: 'Courier New'; color: blue; font-size: 8pt; mso-no-proof: yes;">=</span><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;">"<span style="color: blue;">Windows</span>"<span style="color: blue;"> </span><span style="color: red;">proxyCredentialType</span><span style="color: blue;">=</span>"<span style="color: blue;">Windows</span>"<span style="color: blue;"> </span><span style="color: red;">realm</span><span style="color: blue;">=</span>""<span style="color: blue;"> /&gt;<o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="font-family: 'Courier New'; color: blue; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>&lt;/</span><span style="font-family: 'Courier New'; color: #a31515; font-size: 8pt; mso-no-proof: yes;">security</span><span style="font-family: 'Courier New'; color: blue; font-size: 8pt; mso-no-proof: yes;">&gt;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: 'Courier New'; color: blue; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;</span>&lt;/</span><span style="font-family: 'Courier New'; color: #a31515; font-size: 8pt; mso-no-proof: yes;">binding</span><span style="font-family: 'Courier New'; color: blue; font-size: 8pt; mso-no-proof: yes;">&gt;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: 'Courier New'; color: blue; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;</span>&lt;</span><span style="font-family: 'Courier New'; color: #a31515; font-size: 8pt; mso-no-proof: yes;">binding</span><span style="font-family: 'Courier New'; color: blue; font-size: 8pt; mso-no-proof: yes;"> </span><span style="font-family: 'Courier New'; color: red; font-size: 8pt; mso-no-proof: yes;">name</span><span style="font-family: 'Courier New'; color: blue; font-size: 8pt; mso-no-proof: yes;">=</span><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;">"<span style="color: blue;">mexHttpBinding</span>"<span style="color: blue;">&gt;<o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="font-family: 'Courier New'; color: blue; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>&lt;</span><span style="font-family: 'Courier New'; color: #a31515; font-size: 8pt; mso-no-proof: yes;">security</span><span style="font-family: 'Courier New'; color: blue; font-size: 8pt; mso-no-proof: yes;"> </span><span style="font-family: 'Courier New'; color: red; font-size: 8pt; mso-no-proof: yes;">mode</span><span style="font-family: 'Courier New'; color: blue; font-size: 8pt; mso-no-proof: yes;">=</span><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;">"<span style="color: blue;">TransportCredentialOnly</span>"<span style="color: blue;">&gt;<o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="font-family: 'Courier New'; color: blue; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>&lt;</span><span style="font-family: 'Courier New'; color: #a31515; font-size: 8pt; mso-no-proof: yes;">transport</span><span style="font-family: 'Courier New'; color: blue; font-size: 8pt; mso-no-proof: yes;"> </span><span style="font-family: 'Courier New'; color: red; font-size: 8pt; mso-no-proof: yes;">clientCredentialType</span><span style="font-family: 'Courier New'; color: blue; font-size: 8pt; mso-no-proof: yes;">=</span><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;">"<span style="color: blue;">Windows</span>"<span style="color: blue;"> </span><span style="color: red;">proxyCredentialType</span><span style="color: blue;">=</span>"<span style="color: blue;">Windows</span>"<span style="color: blue;"> </span><span style="color: red;">realm</span><span style="color: blue;">=</span>""<span style="color: blue;"> /&gt;<o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="font-family: 'Courier New'; color: blue; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>&lt;/</span><span style="font-family: 'Courier New'; color: #a31515; font-size: 8pt; mso-no-proof: yes;">security</span><span style="font-family: 'Courier New'; color: blue; font-size: 8pt; mso-no-proof: yes;">&gt;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: 'Courier New'; color: blue; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;</span>&lt;/</span><span style="font-family: 'Courier New'; color: #a31515; font-size: 8pt; mso-no-proof: yes;">binding</span><span style="font-family: 'Courier New'; color: blue; font-size: 8pt; mso-no-proof: yes;">&gt;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: 'Courier New'; color: blue; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;</span>&lt;/</span><span style="font-family: 'Courier New'; color: #a31515; font-size: 8pt; mso-no-proof: yes;">basicHttpBinding</span><span style="font-family: 'Courier New'; color: blue; font-size: 8pt; mso-no-proof: yes;">&gt;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="line-height: 115%; font-family: 'Courier New'; color: blue; font-size: 8pt; mso-no-proof: yes;">&lt;/</span><span style="line-height: 115%; font-family: 'Courier New'; color: #a31515; font-size: 8pt; mso-no-proof: yes;">bindings</span><span style="line-height: 115%; font-family: 'Courier New'; color: blue; font-size: 8pt; mso-no-proof: yes;">&gt;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: small;"><span style="font-family: Calibri;">Note that you may not need to be using streamed responses and your timeouts should probably be a little more aggressive than what I have shown above. While developing the extension service, it may also be useful to you to have a service behavior that allows exception details to be populated into any fault that may occur. The following XML in the &lt;system.serviceModel&gt; section shows how to implement the fault behavior:<o:p></o:p></span></span></p>
<p><span style="font-family: 'Courier New'; color: blue; font-size: 8pt; mso-no-proof: yes;">
<p class="MsoNormal"><span style="font-family: 'Courier New'; color: blue; font-size: 8pt; mso-no-proof: yes;">&lt;</span><span style="font-family: 'Courier New'; color: #a31515; font-size: 8pt; mso-no-proof: yes;">behaviors</span><span style="font-family: 'Courier New'; color: blue; font-size: 8pt; mso-no-proof: yes;">&gt;</span></p>
<p class="MsoNormal"><span style="font-family: 'Courier New'; color: blue; font-size: 8pt; mso-no-proof: yes;">&nbsp; </span><span style="font-family: 'Courier New'; color: blue; font-size: 8pt; mso-no-proof: yes;">&lt;</span><span style="font-family: 'Courier New'; color: #a31515; font-size: 8pt; mso-no-proof: yes;">serviceBehaviors</span><span style="font-family: 'Courier New'; color: blue; font-size: 8pt; mso-no-proof: yes;">&gt;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: 'Courier New'; color: blue; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span>&lt;</span><span style="font-family: 'Courier New'; color: #a31515; font-size: 8pt; mso-no-proof: yes;">behavior</span><span style="font-family: 'Courier New'; color: blue; font-size: 8pt; mso-no-proof: yes;"> </span><span style="font-family: 'Courier New'; color: red; font-size: 8pt; mso-no-proof: yes;">name</span><span style="font-family: 'Courier New'; color: blue; font-size: 8pt; mso-no-proof: yes;">=</span><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"><span style="color: #000000;">"</span><span style="color: blue;">PSIExtensionServiceBehavior</span><span style="color: #000000;">"</span><span style="color: blue;">&gt;<o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="font-family: 'Courier New'; color: blue; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>&lt;</span><span style="font-family: 'Courier New'; color: #a31515; font-size: 8pt; mso-no-proof: yes;">serviceDebug</span><span style="font-family: 'Courier New'; color: blue; font-size: 8pt; mso-no-proof: yes;"> </span><span style="font-family: 'Courier New'; color: red; font-size: 8pt; mso-no-proof: yes;">includeExceptionDetailInFaults</span><span style="font-family: 'Courier New'; color: blue; font-size: 8pt; mso-no-proof: yes;">=</span><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"><span style="color: #000000;">"</span><span style="color: blue;">true</span><span style="color: #000000;">"</span><span style="color: blue;"> /&gt;<o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="font-family: 'Courier New'; color: blue; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>&lt;</span><span style="font-family: 'Courier New'; color: #a31515; font-size: 8pt; mso-no-proof: yes;">serviceMetadata</span><span style="font-family: 'Courier New'; color: blue; font-size: 8pt; mso-no-proof: yes;"> </span><span style="font-family: 'Courier New'; color: red; font-size: 8pt; mso-no-proof: yes;">httpGetEnabled</span><span style="font-family: 'Courier New'; color: blue; font-size: 8pt; mso-no-proof: yes;">=</span><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"><span style="color: #000000;">"</span><span style="color: blue;">true</span><span style="color: #000000;">"</span><span style="color: blue;"> /&gt;<o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="font-family: 'Courier New'; color: blue; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;</span>&lt;/</span><span style="font-family: 'Courier New'; color: #a31515; font-size: 8pt; mso-no-proof: yes;">behavior</span><span style="font-family: 'Courier New'; color: blue; font-size: 8pt; mso-no-proof: yes;">&gt;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: 'Courier New'; color: blue; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;</span>&lt;/</span><span style="font-family: 'Courier New'; color: #a31515; font-size: 8pt; mso-no-proof: yes;">serviceBehaviors</span><span style="font-family: 'Courier New'; color: blue; font-size: 8pt; mso-no-proof: yes;">&gt;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="line-height: 115%; font-family: 'Courier New'; color: blue; font-size: 8pt; mso-no-proof: yes;">&lt;/</span><span style="line-height: 115%; font-family: 'Courier New'; color: #a31515; font-size: 8pt; mso-no-proof: yes;">behaviors</span><span style="line-height: 115%; font-family: 'Courier New'; color: blue; font-size: 8pt; mso-no-proof: yes;">&gt;</span><span style="line-height: 115%; font-size: 8pt;"><o:p></o:p></span></p>
</span></p>
<p class="MsoNormal"><span style="font-size: small;"><span style="font-family: Calibri;">Finally, you&rsquo;ll have to declare the extension service in terms of address. Here is the XML (again in the &lt;system.serviceModel&gt; section):<o:p></o:p></span></span></p>
<p><span style="font-family: 'Courier New'; color: blue; font-size: 8pt; mso-no-proof: yes;">
<p class="MsoNormal"><span style="font-family: 'Courier New'; color: blue; font-size: 8pt; mso-no-proof: yes;">&lt;</span><span style="font-family: 'Courier New'; color: #a31515; font-size: 8pt; mso-no-proof: yes;">services</span><span style="font-family: 'Courier New'; color: blue; font-size: 8pt; mso-no-proof: yes;">&gt;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: 'Courier New'; color: blue; font-size: 8pt; mso-no-proof: yes;">&nbsp; &lt;</span><span style="font-family: 'Courier New'; color: #a31515; font-size: 8pt; mso-no-proof: yes;">service</span><span style="font-family: 'Courier New'; color: blue; font-size: 8pt; mso-no-proof: yes;"> </span><span style="font-family: 'Courier New'; color: red; font-size: 8pt; mso-no-proof: yes;">name</span><span style="font-family: 'Courier New'; color: blue; font-size: 8pt; mso-no-proof: yes;">=</span><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"><span style="color: #000000;">"</span><span style="color: blue;">Project.Server.Extensions.ExtensionPSIService</span><span style="color: #000000;">"<o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="font-family: 'Courier New'; color: blue; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><span style="font-family: 'Courier New'; color: red; font-size: 8pt; mso-no-proof: yes;">behaviorConfiguration</span><span style="font-family: 'Courier New'; color: blue; font-size: 8pt; mso-no-proof: yes;">=</span><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"><span style="color: #000000;">"</span><span style="color: blue;">PSIExtensionServiceBehavior</span><span style="color: #000000;">"</span><span style="color: blue;">&gt;<o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="font-family: 'Courier New'; color: blue; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span>&lt;</span><span style="font-family: 'Courier New'; color: #a31515; font-size: 8pt; mso-no-proof: yes;">endpoint</span><span style="font-family: 'Courier New'; color: blue; font-size: 8pt; mso-no-proof: yes;"> </span><span style="font-family: 'Courier New'; color: red; font-size: 8pt; mso-no-proof: yes;">address</span><span style="font-family: 'Courier New'; color: blue; font-size: 8pt; mso-no-proof: yes;">=</span><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"><span style="color: #000000;">""<o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="font-family: 'Courier New'; color: blue; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><span style="font-family: 'Courier New'; color: red; font-size: 8pt; mso-no-proof: yes;">binding</span><span style="font-family: 'Courier New'; color: blue; font-size: 8pt; mso-no-proof: yes;">=</span><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"><span style="color: #000000;">"</span><span style="color: blue;">basicHttpBinding</span><span style="color: #000000;">"<o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="font-family: 'Courier New'; color: blue; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><span style="font-family: 'Courier New'; color: red; font-size: 8pt; mso-no-proof: yes;">bindingConfiguration</span><span style="font-family: 'Courier New'; color: blue; font-size: 8pt; mso-no-proof: yes;">=</span><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"><span style="color: #000000;">"</span><span style="color: blue;">extensionBasicHttpConf</span><span style="color: #000000;">"<o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="font-family: 'Courier New'; color: blue; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><span style="font-family: 'Courier New'; color: red; font-size: 8pt; mso-no-proof: yes;">contract</span><span style="font-family: 'Courier New'; color: blue; font-size: 8pt; mso-no-proof: yes;">=</span><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"><span style="color: #000000;">"</span><span style="color: blue;">Project.Server.Extensions.IExtensionPSIService</span><span style="color: #000000;">"</span><span style="color: blue;"> /&gt;<o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="font-family: 'Courier New'; color: blue; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;</span>&lt;</span><span style="font-family: 'Courier New'; color: #a31515; font-size: 8pt; mso-no-proof: yes;">endpoint&nbsp;</span><span style="font-family: 'Courier New'; color: red; font-size: 8pt; mso-no-proof: yes;">address</span><span style="font-family: 'Courier New'; color: blue; font-size: 8pt; mso-no-proof: yes;">=</span><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"><span style="color: #000000;">"</span><span style="color: blue;">mex</span><span style="color: #000000;">"<o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="font-family: 'Courier New'; color: blue; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><span style="font-family: 'Courier New'; color: red; font-size: 8pt; mso-no-proof: yes;">binding</span><span style="font-family: 'Courier New'; color: blue; font-size: 8pt; mso-no-proof: yes;">=</span><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"><span style="color: #000000;">"</span><span style="color: blue;">basicHttpBinding</span><span style="color: #000000;">"<o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="font-family: 'Courier New'; color: blue; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><span style="font-family: 'Courier New'; color: red; font-size: 8pt; mso-no-proof: yes;">bindingConfiguration</span><span style="font-family: 'Courier New'; color: blue; font-size: 8pt; mso-no-proof: yes;">=</span><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"><span style="color: #000000;">"</span><span style="color: blue;">mexHttpBinding</span><span style="color: #000000;">"<o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="font-family: 'Courier New'; color: blue; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><span style="font-family: 'Courier New'; color: red; font-size: 8pt; mso-no-proof: yes;">name</span><span style="font-family: 'Courier New'; color: blue; font-size: 8pt; mso-no-proof: yes;">=</span><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"><span style="color: #000000;">"</span><span style="color: blue;">mex</span><span style="color: #000000;">"<o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="font-family: 'Courier New'; color: blue; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><span style="font-family: 'Courier New'; color: red; font-size: 8pt; mso-no-proof: yes;">contract</span><span style="font-family: 'Courier New'; color: blue; font-size: 8pt; mso-no-proof: yes;">=</span><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"><span style="color: #000000;">"</span><span style="color: blue;">IMetadataExchange</span><span style="color: #000000;">"</span><span style="color: blue;"> /&gt;<o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="font-family: 'Courier New'; color: blue; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;</span>&lt;/</span><span style="font-family: 'Courier New'; color: #a31515; font-size: 8pt; mso-no-proof: yes;">service</span><span style="font-family: 'Courier New'; color: blue; font-size: 8pt; mso-no-proof: yes;">&gt;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="line-height: 115%; font-family: 'Courier New'; color: blue; font-size: 8pt; mso-no-proof: yes;">&lt;/</span><span style="line-height: 115%; font-family: 'Courier New'; color: #a31515; font-size: 8pt; mso-no-proof: yes;">services</span><span style="line-height: 115%; font-family: 'Courier New'; color: blue; font-size: 8pt; mso-no-proof: yes;">&gt;<o:p></o:p></span></p>
</span></p>
<p class="MsoNormal"><span style="font-size: small;"><span style="font-family: Calibri;">With this addition to the config file, we have now declared the address that the extension service will be listening to, we have declared what binding will be used and finally we have the contract exposed by the service. Additionally, we have a metadata exchange (MEX) endpoint &ndash; useful for creating clients. This is something that you may or may not want in a production environment. <o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="font-size: small;"><span style="font-family: Calibri;">The next thing to do is to create the activation file. This is the file, when requested will initiate the activation of your service. By default, this file is called &lt;service name&gt;.svc and is placed in the same location as the web.config file that holds the configuration entries for the service. Note that the name you chose for the activation file is what you will be putting in the request URL when you try to access the service. I have named mine Service.svc, with the following content: <o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="font-family: 'Courier New'; background: yellow; font-size: 8pt; mso-no-proof: yes; mso-highlight: yellow;">&lt;%</span><span style="font-family: 'Courier New'; color: blue; font-size: 8pt; mso-no-proof: yes;">@</span><span style="font-family: 'Courier New'; color: #a31515; font-size: 8pt; mso-no-proof: yes;">ServiceHost</span><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"> <span style="color: red;">language</span><span style="color: blue;">="C#"<o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="line-height: 115%; font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: red;">service</span><span style="color: blue;">="&lt;Fully qualified type name&gt;, Version=1.0.0.0, Culture=neutral, PublicKeyToken=&lt;PublicKeyToken of your assembly&gt;"</span> <span style="background: yellow; mso-highlight: yellow;">%&gt;</span><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: small;"><span style="font-family: Calibri;">PSIExtensions is the name of the assembly that holds the service implementation. As you can see, I have strongly signed the assembly and put it in the GAC.<o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="font-size: small;"><span style="font-family: Calibri;">With all the configuration work behind us, we can now write the actual service. This will be the topic of the next part of this post, but for now I will explain how to get the skeleton up and running. In Visual Studio 2008 or Visual Studio 2010, create a new class library (you may also use the template to create a WCF service library &ndash; I typically do not because it creates more files than I need, and I like to be in total control as to what goes where).<o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="font-size: small;"><span style="font-family: Calibri;">Add a reference to <b style="mso-bidi-font-weight: normal;">System.ServiceModel</b> for your class library, and add a new code file that will have the interface definition. It should, for now, look like this:<o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="font-family: 'Courier New'; color: blue; font-size: 8pt; mso-no-proof: yes;">namespace</span><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"> Project.Server.Extensions<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;">{<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp; </span>[<span style="color: #2b91af;">ServiceContract</span>]<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp; </span><span style="color: blue;">internal</span> <span style="color: blue;">interface</span> <span style="color: #2b91af;">IExtensionPSIService<o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp; </span>{<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>[<span style="color: #2b91af;">OperationContract</span>]<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">string</span> EchoHello();<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp; </span>}<o:p></o:p></span></p>
<p class="MsoNormal"><span style="line-height: 115%; font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;">}</span><span style="line-height: 115%; font-size: 8pt;"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: small;"><span style="font-family: Calibri;">Now, all we need is to have the actual service implementation. For that, add a new class to your assembly with the following content: <o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="font-family: 'Courier New'; color: blue; font-size: 8pt; mso-no-proof: yes;">namespace</span><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"> Project.Server.Extensions<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;">{<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp; </span>[<span style="color: #2b91af;">AspNetCompatibilityRequirements</span>(RequirementsMode =<span style="color: #2b91af;">&nbsp;AspNetCompatibilityRequirementsMode</span>.Allowed)]<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp; </span><span style="color: blue;">internal</span> <span style="color: blue;">class</span> <span style="color: #2b91af;">ExtensionPSIService</span> : <span style="color: #2b91af;">IExtensionPSIService<o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp; </span>{<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: 'Courier New'; color: blue; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>#region</span><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"> IExtensionPSIService Members<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">public</span> <span style="color: blue;">string</span> EchoHello()<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>{<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">return</span> <span style="color: red;">"Hello"</span>;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>}<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span style="font-family: 'Courier New'; color: blue; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>#endregion<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp; </span>}<o:p></o:p></span></p>
<p class="MsoNormal"><span style="line-height: 115%; font-family: 'Courier New'; font-size: 8pt; mso-no-proof: yes;">}</span><span style="line-height: 115%; font-size: 8pt;"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Calibri; font-size: small;">The </span><span style="line-height: 115%; font-family: 'Courier New'; color: #2b91af; font-size: 10pt; mso-no-proof: yes;">AspNetCompatibilityRequirements</span><span style="font-size: small;"><span style="font-family: Calibri;"> attribute is needed as the web application that hosts your extension service (and the Project Server front-end service) requires ASP.NET compatibility &ndash; if you omit this attribute declaration, your service cannot be activated.<o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="font-size: small;"><span style="font-family: Calibri;">You should now be able to compile, register in the GAC, and activate the service. Open a browser and target the service activation file that you created. In my case, since I have deployed PWA in a &ldquo;sub-site&rdquo; called PWA, the URL looks like this: <span style="mso-field-code: ' HYPERLINK ';"><span class="MsoHyperlink"><span style="text-decoration: underline;"><span style="color: #0000ff;">https://&lt;servername&gt;/pwa/_vti_bin/PSI/Service.svc</span></span></span></span> (assuming that you have your PWA instance in an app called &ldquo;pwa&rdquo; &ndash; please update your URLs accordingly if that is not the case).<o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="font-size: small;"><span style="font-family: Calibri;">You should be getting the well-known &ldquo;You have created a service.&rdquo; page.<o:p></o:p></span></span></p>]]></content:encoded>
    </item>
    <item>
      <title>The server committed a protocol violation</title>
      <link>https://docs.microsoft.com/archive/blogs/thelever/the-server-committed-a-protocol-violation</link>
      <pubDate>Fri, 23 Jan 2009 13:14:00 GMT</pubDate>
      <dc:creator><![CDATA[thelever]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/thelever/2009/01/23/the-server-committed-a-protocol-violation/</guid>
      <description><![CDATA[For the longest time I was having problems calling my WCF server, where the message in the exception...]]></description>
      <content:encoded><![CDATA[<P>For the longest time I was having problems calling my WCF server, where the message in the exception I got client side was this:</P>
<P>"The server committed a protocol violation. Section=ResponseBody Detail=Response chunk format is invalid"</P>
<P>For the longest time I had no clue as to what was going on. I tried searching the web, but I found very few (only a hand full, I think) references, and none of those references seemed to make sense in my context (actually, I am hoping that this post will get indexed such that people facing the same may hit this post and maybe be helped out. I know... The good samaritan!). I tried enabling tracing, but I didn't see anything that jumped out at me. It has to be said, though, that I am by no means a master at reading those traces. I tried using Fiddler, but for some reason that caused to halt the response from my service to the client -- I still have to work out why that is. I tried with Network Monitor, but I drowned in the sea of frames it reported.</P>
<P>I enlisted the help of some of the people in the WCF framework team, and pretty quickly, we got some traction. The first thing that stood out was that the communication between client and the server was chunked. In the HTTP 1.1 spec, it states that if you use chunking, you (the server) has to provide the chunking length. In my case that was missing. After further input from the WCF people, the solution was very simple: Before returning the message to the client, simply clear all properties on the message (using <FONT face="courier new,courier">Properties.Clear()</FONT> on the message in question).</P>
<P>I hope this will help those of you who are unfortunate enough to run into this one.</P>
<P><STRONG>EDIT:</STRONG> After talking a bit more to the people in WCF, it turns out that this is most likely expected behavior. See this <A class="" title="Message Properties" href="https://msdn.microsoft.com/en-us/library/ms734675.aspx" target=_blank mce_href="https://msdn.microsoft.com/en-us/library/ms734675.aspx">MSDN article</A>, specifically the "Working with Properties" section. Specifically, this sentence explains it: </P>
<P><EM>"Normally, property values do not map directly to any part of the message on the wire, but rather provide various message processing hints to the various channels in the WCF channel stack or to the <B>CopyTo</B> service framework"</EM></P>]]></content:encoded>
    </item>
    <item>
      <title>A great book!</title>
      <link>https://docs.microsoft.com/archive/blogs/thelever/a-great-book</link>
      <pubDate>Thu, 18 Dec 2008 10:10:00 GMT</pubDate>
      <dc:creator><![CDATA[thelever]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/thelever/2008/12/18/a-great-book/</guid>
      <description><![CDATA[Recently, I came across a book that should be a "must-read" for all developers intending to write...]]></description>
      <content:encoded><![CDATA[<P>Recently, I came across a book that should be a "must-read" for all developers intending to write performant, scalable code. Inevitably, you will have to consider multithreading, and so your path is beset with all kinds of trouble if you don't get things right. Helping you along your way is <A title="Concurrent Programming on Windows" target=_blank href="https://www.amazon.com/Concurrent-Programming-Windows-Microsoft-Development/dp/032143482X/ref=pd_bbs_sr_1?ie=UTF8&amp;s=books&amp;qid=1229613272&amp;sr=8-1" mce_href="https://www.amazon.com/Concurrent-Programming-Windows-Microsoft-Development/dp/032143482X/ref=pd_bbs_sr_1?ie=UTF8&amp;s=books&amp;qid=1229613272&amp;sr=8-1">this book</A>. I got the book a couple of weeks ago, and it became my constant companion: Whenever I had a couple of minutes (that is when Daniel allowed it), I would be reading it (and still am). I have even brought it with me on vacation: I am in Europe, and my trusty book is with me!</P>
<P>I like the way I am being brough back to the school bench while the simples concepts are explained eloquently and efficiently. Then, as you turn each page, things get progressively more complex in such a well thought out stream of info. Get it. Read it. Enjoy it!</P>]]></content:encoded>
    </item>
    <item>
      <title>A Question of Hardware</title>
      <link>https://docs.microsoft.com/archive/blogs/thelever/a-question-of-hardware</link>
      <pubDate>Tue, 09 Dec 2008 11:50:00 GMT</pubDate>
      <dc:creator><![CDATA[thelever]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/thelever/2008/12/09/a-question-of-hardware/</guid>
      <description><![CDATA[Someone asked me what sort of hardware I am going to be running this little project on. This is good...]]></description>
      <content:encoded><![CDATA[<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><FONT size=3 face=Calibri>Someone asked me what sort of hardware I am going to be running this little project on. This is good news: Someone is reading what I write! Always makes me happy, and makes me keen to answer. So, here goes...</FONT></P>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><FONT size=3 face=Calibri>In all simplicity, most of the heavy lifting will be done by FSX/ESP for rendering the outside views from the cockpit and doing the physics calculations that are needed to model flight. I am most likely not hooking up extra hardware (interface boards, that is) to the box that runs FSX/ESP. This is despite the fact that I wrote a small app to poll the joystick at a certain frequency (it varied in my tests from 10 Hz to 60 Hz) just to see what the cost of such an app would be in terms of resource usage. It was barely noticable! I don't know if that is because I used CCR or not, but one thing is sure: CCR made it extremely easy to write. I ran this app on a dual core. I forget what the specs of that box is, but it is a fairly old Dell Dimension 9100 with 2 Gb RAM.</FONT></P>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><FONT size=3 face=Calibri>Continuing this train of thought: I think the boxes that will actually be running the interface software will be the cheapest boxes I can find online. I looked at assembling such a box from spare parts found online, and the tally came out to be about $200. With prices like that, it seems that the over all cost of this little project will come from knobs and switches that make it look like the real thing, not from the computers that do the hardware I/O (with the exception of the main FSX/ESP computer, which I hope will be a beast of dimensions).</FONT></P>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><FONT size=3 face=Calibri>The code that runs the polling of the joystick is given below. Again, the Interleave arbiter is your friend (or, mine at least. You could potentially rewrite this using other constructs, I have just come to love the Interleave arbiter with all my soul).</FONT></P><SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes">
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes">internal</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><FONT color=#000000> </FONT><SPAN style="COLOR: blue">delegate</SPAN><FONT color=#000000> </FONT><SPAN style="COLOR: blue">void</SPAN><FONT color=#000000> </FONT><SPAN style="COLOR: #2b91af">TimerDelegate</SPAN><FONT color=#000000>(</FONT><SPAN style="COLOR: blue">object</SPAN><FONT color=#000000> state);<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p></FONT></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><o:p><FONT color=#000000>&nbsp;</FONT></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes">internal</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><FONT color=#000000> </FONT><SPAN style="COLOR: blue">sealed</SPAN><FONT color=#000000> </FONT><SPAN style="COLOR: blue">class</SPAN><FONT color=#000000> </FONT><SPAN style="COLOR: #2b91af">SchedulerCompletion<o:p></o:p></SPAN></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><FONT color=#000000>{<o:p></o:p></FONT></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><FONT color=#000000>}<o:p></o:p></FONT></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><o:p><FONT color=#000000>&nbsp;</FONT></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes">internal</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><FONT color=#000000> </FONT><SPAN style="COLOR: blue">class</SPAN><FONT color=#000000> </FONT><SPAN style="COLOR: #2b91af">FBWTaskScheduler</SPAN><FONT color=#000000> : </FONT><SPAN style="COLOR: #2b91af">IDisposable<o:p></o:p></SPAN></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><FONT color=#000000>{<o:p></o:p></FONT></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes"><FONT color=#000000>&nbsp;&nbsp; </FONT></SPAN><SPAN style="COLOR: blue">private</SPAN><FONT color=#000000> </FONT><SPAN style="COLOR: blue">class</SPAN><FONT color=#000000> </FONT><SPAN style="COLOR: #2b91af">TimerJobInfo<o:p></o:p></SPAN></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><FONT color=#000000><SPAN style="mso-spacerun: yes">&nbsp;&nbsp; </SPAN>{<o:p></o:p></FONT></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes"><FONT color=#000000>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </FONT></SPAN><SPAN style="COLOR: blue">public</SPAN><FONT color=#000000> </FONT><SPAN style="COLOR: blue">double</SPAN><FONT color=#000000> Frequency<o:p></o:p></FONT></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><FONT color=#000000><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>{ </FONT><SPAN style="COLOR: blue">get</SPAN><FONT color=#000000>; </FONT><SPAN style="COLOR: blue">set</SPAN><FONT color=#000000>; }<o:p></o:p></FONT></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><FONT color=#000000><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><o:p></o:p></FONT></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes"><FONT color=#000000>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </FONT></SPAN><SPAN style="COLOR: blue">public</SPAN><FONT color=#000000> </FONT><SPAN style="COLOR: #2b91af">TimerDelegate</SPAN><FONT color=#000000> TimerFunc<o:p></o:p></FONT></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><FONT color=#000000><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>{ </FONT><SPAN style="COLOR: blue">get</SPAN><FONT color=#000000>; </FONT><SPAN style="COLOR: blue">set</SPAN><FONT color=#000000>; }<o:p></o:p></FONT></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><FONT color=#000000><SPAN style="mso-spacerun: yes">&nbsp;&nbsp; </SPAN>}<o:p></o:p></FONT></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><o:p><FONT color=#000000>&nbsp;</FONT></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes"><FONT color=#000000>&nbsp;&nbsp; </FONT></SPAN><SPAN style="COLOR: blue">private</SPAN><FONT color=#000000> </FONT><SPAN style="COLOR: #2b91af">Dispatcher</SPAN><FONT color=#000000> dispatcher;<o:p></o:p></FONT></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes"><FONT color=#000000>&nbsp;&nbsp; </FONT></SPAN><SPAN style="COLOR: blue">private</SPAN><FONT color=#000000> </FONT><SPAN style="COLOR: #2b91af">DispatcherQueue</SPAN><FONT color=#000000> taskQueue;<o:p></o:p></FONT></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><FONT color=#000000><SPAN style="mso-spacerun: yes">&nbsp;&nbsp; </SPAN><o:p></o:p></FONT></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes"><FONT color=#000000>&nbsp;&nbsp; </FONT></SPAN><SPAN style="COLOR: blue">private</SPAN><FONT color=#000000> </FONT><SPAN style="COLOR: #2b91af">Port</SPAN><FONT color=#000000>&lt;</FONT><SPAN style="COLOR: #2b91af">DateTime</SPAN><FONT color=#000000>&gt; timerPort;<o:p></o:p></FONT></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes"><FONT color=#000000>&nbsp;&nbsp; </FONT></SPAN><SPAN style="COLOR: blue">private</SPAN><FONT color=#000000> </FONT><SPAN style="COLOR: #2b91af">TimerJobInfo</SPAN><FONT color=#000000> timerJobInfo;<o:p></o:p></FONT></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><o:p><FONT color=#000000>&nbsp;</FONT></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes"><FONT color=#000000>&nbsp;&nbsp; </FONT></SPAN><SPAN style="COLOR: blue">private</SPAN><FONT color=#000000> </FONT><SPAN style="COLOR: #2b91af">PortSet</SPAN><FONT color=#000000>&lt;</FONT><SPAN style="COLOR: #2b91af">SchedulerCompletion</SPAN><FONT color=#000000>, </FONT><SPAN style="COLOR: #2b91af">Exception</SPAN><FONT color=#000000>&gt; terminatingPort;<o:p></o:p></FONT></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><o:p><FONT color=#000000>&nbsp;</FONT></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes"><FONT color=#000000>&nbsp;&nbsp; </FONT></SPAN><SPAN style="COLOR: blue">private</SPAN><FONT color=#000000> </FONT><SPAN style="COLOR: blue">bool</SPAN><FONT color=#000000> hasTimerJob;<o:p></o:p></FONT></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><o:p><FONT color=#000000>&nbsp;</FONT></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes"><FONT color=#000000>&nbsp;&nbsp; </FONT></SPAN><SPAN style="COLOR: blue">private</SPAN><FONT color=#000000> </FONT><SPAN style="COLOR: blue">static</SPAN><FONT color=#000000> </FONT><SPAN style="COLOR: blue">object</SPAN><FONT color=#000000> syncLock = </FONT><SPAN style="COLOR: blue">new</SPAN><FONT color=#000000> </FONT><SPAN style="COLOR: blue">object</SPAN><FONT color=#000000>();<o:p></o:p></FONT></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><o:p><FONT color=#000000>&nbsp;</FONT></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes"><FONT color=#000000>&nbsp;&nbsp; </FONT></SPAN><SPAN style="COLOR: blue">public</SPAN><FONT color=#000000> TaskScheduler()<o:p></o:p></FONT></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><FONT color=#000000><SPAN style="mso-spacerun: yes">&nbsp;&nbsp; </SPAN>{<o:p></o:p></FONT></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes"><FONT color=#000000>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </FONT></SPAN><SPAN style="COLOR: blue">this</SPAN><FONT color=#000000>.timerPort = </FONT><SPAN style="COLOR: blue">new</SPAN><FONT color=#000000> </FONT><SPAN style="COLOR: #2b91af">Port</SPAN><FONT color=#000000>&lt;</FONT><SPAN style="COLOR: #2b91af">DateTime</SPAN><FONT color=#000000>&gt;();<o:p></o:p></FONT></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes"><FONT color=#000000>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </FONT></SPAN><SPAN style="COLOR: blue">this</SPAN><FONT color=#000000>.terminatingPort = </FONT><SPAN style="COLOR: blue">new</SPAN><FONT color=#000000> </FONT><SPAN style="COLOR: #2b91af">PortSet</SPAN><FONT color=#000000>&lt;</FONT><SPAN style="COLOR: #2b91af">SchedulerCompletion</SPAN><FONT color=#000000>, </FONT><SPAN style="COLOR: #2b91af">Exception</SPAN><FONT color=#000000>&gt;();<o:p></o:p></FONT></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><o:p><FONT color=#000000>&nbsp;</FONT></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes"><FONT color=#000000>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </FONT></SPAN><SPAN style="COLOR: blue">this</SPAN><FONT color=#000000>.dispatcher = </FONT><SPAN style="COLOR: blue">new</SPAN><FONT color=#000000> </FONT><SPAN style="COLOR: #2b91af">Dispatcher</SPAN><FONT color=#000000>(</FONT><SPAN style="COLOR: navy">0</SPAN><FONT color=#000000>, </FONT><SPAN style="COLOR: red">"TaskScheduler"</SPAN><FONT color=#000000>);<o:p></o:p></FONT></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes"><FONT color=#000000>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </FONT></SPAN><SPAN style="COLOR: blue">this</SPAN><FONT color=#000000>.taskQueue = </FONT><SPAN style="COLOR: blue">new</SPAN><FONT color=#000000> </FONT><SPAN style="COLOR: #2b91af">DispatcherQueue</SPAN><FONT color=#000000>(</FONT><SPAN style="COLOR: red">"TaskQueue"</SPAN><FONT color=#000000>, dispatcher);<o:p></o:p></FONT></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><o:p><FONT color=#000000>&nbsp;</FONT></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes"><FONT color=#000000>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </FONT></SPAN><SPAN style="COLOR: blue">this</SPAN><FONT color=#000000>.taskQueue.Suspend();<o:p></o:p></FONT></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><FONT color=#000000><SPAN style="mso-spacerun: yes">&nbsp;&nbsp; </SPAN>}<o:p></o:p></FONT></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><o:p><FONT color=#000000>&nbsp;</FONT></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes"><FONT color=#000000>&nbsp;&nbsp; </FONT></SPAN><SPAN style="COLOR: blue">public</SPAN><FONT color=#000000> </FONT><SPAN style="COLOR: blue">void</SPAN><FONT color=#000000> EnqueueTimerJob(</FONT><SPAN style="COLOR: blue">double</SPAN><FONT color=#000000> frequency, </FONT><SPAN style="COLOR: #2b91af">TimerDelegate</SPAN><FONT color=#000000> timerFunc)<o:p></o:p></FONT></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><FONT color=#000000><SPAN style="mso-spacerun: yes">&nbsp;&nbsp; </SPAN>{<o:p></o:p></FONT></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes"><FONT color=#000000>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </FONT></SPAN><SPAN style="COLOR: blue">lock</SPAN><FONT color=#000000> (syncLock)<o:p></o:p></FONT></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><FONT color=#000000><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>{<o:p></o:p></FONT></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes"><FONT color=#000000>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </FONT></SPAN><SPAN style="COLOR: blue">if</SPAN><FONT color=#000000> (hasTimerJob)<o:p></o:p></FONT></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><FONT color=#000000><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>{<o:p></o:p></FONT></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes"><FONT color=#000000>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </FONT></SPAN><SPAN style="COLOR: blue">throw</SPAN><FONT color=#000000> </FONT><SPAN style="COLOR: blue">new</SPAN><FONT color=#000000> </FONT><SPAN style="COLOR: #2b91af">InvalidOperationException</SPAN><FONT color=#000000>(</FONT><SPAN style="COLOR: red">"Only one timer job can be enqueued"</SPAN><FONT color=#000000>);<o:p></o:p></FONT></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><FONT color=#000000><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>}<o:p></o:p></FONT></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><o:p><FONT color=#000000>&nbsp;</FONT></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><FONT color=#000000><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>hasTimerJob = </FONT><SPAN style="COLOR: blue">true</SPAN><FONT color=#000000>;<o:p></o:p></FONT></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes"><FONT color=#000000>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </FONT></SPAN><SPAN style="COLOR: blue">if</SPAN><FONT color=#000000> (</FONT><SPAN style="COLOR: blue">null</SPAN><FONT color=#000000> == </FONT><SPAN style="COLOR: blue">this</SPAN><FONT color=#000000>.timerJobInfo)<o:p></o:p></FONT></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><FONT color=#000000><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>{<o:p></o:p></FONT></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes"><FONT color=#000000>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </FONT></SPAN><SPAN style="COLOR: blue">this</SPAN><FONT color=#000000>.timerJobInfo = </FONT><SPAN style="COLOR: blue">new</SPAN><FONT color=#000000> </FONT><SPAN style="COLOR: #2b91af">TimerJobInfo</SPAN><FONT color=#000000>();<o:p></o:p></FONT></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes"><FONT color=#000000>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </FONT></SPAN><SPAN style="COLOR: blue">this</SPAN><FONT color=#000000>.timerJobInfo.Frequency = frequency;<o:p></o:p></FONT></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes"><FONT color=#000000>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </FONT></SPAN><SPAN style="COLOR: blue">this</SPAN><FONT color=#000000>.timerJobInfo.TimerFunc = timerFunc;<o:p></o:p></FONT></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><FONT color=#000000><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>}<o:p></o:p></FONT></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><FONT color=#000000><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>}<o:p></o:p></FONT></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><FONT color=#000000><SPAN style="mso-spacerun: yes">&nbsp;&nbsp; </SPAN>}<o:p></o:p></FONT></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><o:p><FONT color=#000000>&nbsp;</FONT></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes"><FONT color=#000000>&nbsp;&nbsp; </FONT></SPAN><SPAN style="COLOR: blue">public</SPAN><FONT color=#000000> </FONT><SPAN style="COLOR: blue">void</SPAN><FONT color=#000000> Stop()<o:p></o:p></FONT></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><FONT color=#000000><SPAN style="mso-spacerun: yes">&nbsp;&nbsp; </SPAN>{<o:p></o:p></FONT></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes"><FONT color=#000000>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </FONT></SPAN><SPAN style="COLOR: blue">this</SPAN><FONT color=#000000>.terminatingPort.Post(</FONT><SPAN style="COLOR: blue">new</SPAN><FONT color=#000000> </FONT><SPAN style="COLOR: #2b91af">SchedulerCompletion</SPAN><FONT color=#000000>());<o:p></o:p></FONT></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><FONT color=#000000><SPAN style="mso-spacerun: yes">&nbsp;&nbsp; </SPAN>}<o:p></o:p></FONT></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><o:p><FONT color=#000000>&nbsp;</FONT></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes"><FONT color=#000000>&nbsp;&nbsp; </FONT></SPAN><SPAN style="COLOR: blue">public</SPAN><FONT color=#000000> </FONT><SPAN style="COLOR: blue">void</SPAN><FONT color=#000000> Execute()<o:p></o:p></FONT></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><FONT color=#000000><SPAN style="mso-spacerun: yes">&nbsp;&nbsp; </SPAN>{<o:p></o:p></FONT></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes"><FONT color=#000000>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </FONT></SPAN><SPAN style="COLOR: #2b91af">TeardownReceiverGroup</SPAN><FONT color=#000000> failureOrCompletionGroup = </FONT><SPAN style="COLOR: blue">new</SPAN><FONT color=#000000> </FONT><SPAN style="COLOR: #2b91af">TeardownReceiverGroup</SPAN><FONT color=#000000>(<o:p></o:p></FONT></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes"><FONT color=#000000>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </FONT></SPAN><SPAN style="COLOR: #2b91af">Arbiter</SPAN><FONT color=#000000>.Receive&lt;</FONT><SPAN style="COLOR: #2b91af">Exception</SPAN><FONT color=#000000>&gt;(</FONT><SPAN style="COLOR: blue">false</SPAN><FONT color=#000000>, terminatingPort, exception =&gt;<o:p></o:p></FONT></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><FONT color=#000000><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>{<o:p></o:p></FONT></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes"><FONT color=#000000>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </FONT></SPAN><SPAN style="COLOR: #2b91af">Console</SPAN><FONT color=#000000>.WriteLine(</FONT><SPAN style="COLOR: red">"Got exception "</SPAN><FONT color=#000000> + exception.Message);<o:p></o:p></FONT></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><FONT color=#000000><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>}),<o:p></o:p></FONT></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes"><FONT color=#000000>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </FONT></SPAN><SPAN style="COLOR: #2b91af">Arbiter</SPAN><FONT color=#000000>.Receive&lt;</FONT><SPAN style="COLOR: #2b91af">SchedulerCompletion</SPAN><FONT color=#000000>&gt;(</FONT><SPAN style="COLOR: blue">false</SPAN><FONT color=#000000>, terminatingPort, contextCompletion =&gt;<o:p></o:p></FONT></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><FONT color=#000000><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>{<o:p></o:p></FONT></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes"><FONT color=#000000>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </FONT></SPAN><SPAN style="COLOR: #2b91af">Console</SPAN><FONT color=#000000>.WriteLine(</FONT><SPAN style="COLOR: red">"Completed context"</SPAN><FONT color=#000000>);<o:p></o:p></FONT></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><FONT color=#000000><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>}));<o:p></o:p></FONT></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><o:p><FONT color=#000000>&nbsp;</FONT></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes"><FONT color=#000000>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </FONT></SPAN><SPAN style="COLOR: #2b91af">ExclusiveReceiverGroup</SPAN><FONT color=#000000> exclusiveGroup = </FONT><SPAN style="COLOR: blue">new</SPAN><FONT color=#000000> </FONT><SPAN style="COLOR: #2b91af">ExclusiveReceiverGroup</SPAN><FONT color=#000000>();<o:p></o:p></FONT></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><o:p><FONT color=#000000>&nbsp;</FONT></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes"><FONT color=#000000>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </FONT></SPAN><SPAN style="COLOR: #2b91af">ConcurrentReceiverGroup</SPAN><FONT color=#000000> concurrentGroup = </FONT><SPAN style="COLOR: blue">new</SPAN><FONT color=#000000> </FONT><SPAN style="COLOR: #2b91af">ConcurrentReceiverGroup</SPAN><FONT color=#000000>(<o:p></o:p></FONT></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes"><FONT color=#000000>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </FONT></SPAN><SPAN style="COLOR: #2b91af">Arbiter</SPAN><FONT color=#000000>.Receive&lt;</FONT><SPAN style="COLOR: #2b91af">DateTime</SPAN><FONT color=#000000>&gt;(</FONT><SPAN style="COLOR: blue">true</SPAN><FONT color=#000000>, </FONT><SPAN style="COLOR: blue">this</SPAN><FONT color=#000000>.timerPort, dateTime =&gt;<o:p></o:p></FONT></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><FONT color=#000000><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>{<o:p></o:p></FONT></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes"><FONT color=#000000>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </FONT></SPAN><SPAN style="COLOR: blue">if</SPAN><FONT color=#000000> (</FONT><SPAN style="COLOR: blue">null</SPAN><FONT color=#000000> != </FONT><SPAN style="COLOR: blue">this</SPAN><FONT color=#000000>.timerJobInfo)<o:p></o:p></FONT></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><FONT color=#000000><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>{<o:p></o:p></FONT></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes"><FONT color=#000000>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </FONT></SPAN><SPAN style="COLOR: blue">try<o:p></o:p></SPAN></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><FONT color=#000000><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>{<o:p></o:p></FONT></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><FONT color=#000000><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>timerJobInfo.TimerFunc(dateTime);<o:p></o:p></FONT></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><FONT color=#000000><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>}<o:p></o:p></FONT></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><FONT color=#000000><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;</SPAN></FONT><SPAN style="COLOR: blue">catch</SPAN><FONT color=#000000> (</FONT><SPAN style="COLOR: #2b91af">Exception</SPAN><FONT color=#000000> e)<o:p></o:p></FONT></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><FONT color=#000000><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>{<o:p></o:p></FONT></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes"><FONT color=#000000>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </FONT></SPAN><SPAN style="COLOR: blue">this</SPAN><FONT color=#000000>.terminatingPort.Post(e);<o:p></o:p></FONT></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><FONT color=#000000><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>}<o:p></o:p></FONT></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><o:p><FONT color=#000000>&nbsp;</FONT></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><FONT color=#000000><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN></FONT><SPAN style="COLOR: blue">this</SPAN><FONT color=#000000>.taskQueue.EnqueueTimer(</FONT><SPAN style="COLOR: #2b91af">TimeSpan</SPAN><FONT color=#000000>.FromMilliseconds(</FONT><SPAN style="COLOR: navy">1000</SPAN><FONT color=#000000> / timerJobInfo.Frequency), </FONT><SPAN style="COLOR: blue">this</SPAN><FONT color=#000000>.timerPort);<o:p></o:p></FONT></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><FONT color=#000000><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>}<o:p></o:p></FONT></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><FONT color=#000000><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN>}));<o:p></o:p></FONT></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><o:p><FONT color=#000000>&nbsp;</FONT></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><FONT color=#000000><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-spacerun: yes">&nbsp;</SPAN></FONT><SPAN style="COLOR: #2b91af">Arbiter</SPAN><FONT color=#000000>.Activate(</FONT><SPAN style="COLOR: blue">this</SPAN><FONT color=#000000>.taskQueue,<o:p></o:p></FONT></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><FONT color=#000000><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;</SPAN></FONT><SPAN style="COLOR: #2b91af">Arbiter</SPAN><FONT color=#000000>.Interleave(failureOrCompletionGroup,<o:p></o:p></FONT></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><FONT color=#000000><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN>exclusiveGroup,<o:p></o:p></FONT></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><FONT color=#000000><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN>concurrentGroup));<o:p></o:p></FONT></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><o:p><FONT color=#000000>&nbsp;</FONT></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><FONT color=#000000><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-spacerun: yes">&nbsp;</SPAN></FONT><SPAN style="COLOR: blue">if</SPAN><FONT color=#000000> (</FONT><SPAN style="COLOR: blue">null</SPAN><FONT color=#000000> != </FONT><SPAN style="COLOR: blue">this</SPAN><FONT color=#000000>.timerJobInfo)<o:p></o:p></FONT></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><FONT color=#000000><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;</SPAN><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;</SPAN>StartTimerJob();<o:p></o:p></FONT></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><o:p><FONT color=#000000>&nbsp;</FONT></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><FONT color=#000000><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-spacerun: yes">&nbsp;</SPAN></FONT><SPAN style="COLOR: blue">if</SPAN><FONT color=#000000> (</FONT><SPAN style="COLOR: blue">this</SPAN><FONT color=#000000>.taskQueue.IsSuspended)<o:p></o:p></FONT></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><FONT color=#000000><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;</SPAN></FONT><SPAN style="COLOR: blue">this</SPAN><FONT color=#000000>.taskQueue.Resume();<o:p></o:p></FONT></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><FONT color=#000000><SPAN style="mso-spacerun: yes">&nbsp;&nbsp; </SPAN>}<o:p></o:p></FONT></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><o:p><FONT color=#000000>&nbsp;</FONT></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes"><FONT color=#000000>&nbsp;&nbsp; </FONT></SPAN><SPAN style="COLOR: blue">private</SPAN><FONT color=#000000> </FONT><SPAN style="COLOR: blue">void</SPAN><FONT color=#000000> StartTimerJob()<o:p></o:p></FONT></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><FONT color=#000000><SPAN style="mso-spacerun: yes">&nbsp;&nbsp; </SPAN>{<o:p></o:p></FONT></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes"><FONT color=#000000>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </FONT></SPAN><SPAN style="COLOR: blue">this</SPAN><FONT color=#000000>.taskQueue.EnqueueTimer(</FONT><SPAN style="COLOR: #2b91af">TimeSpan</SPAN><FONT color=#000000>.FromMilliseconds(</FONT><SPAN style="COLOR: navy">1000</SPAN><FONT color=#000000> / timerJobInfo.Frequency),<o:p></o:p></FONT></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><FONT color=#000000><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>timerPort);<o:p></o:p></FONT></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><FONT color=#000000><SPAN style="mso-spacerun: yes">&nbsp;&nbsp; </SPAN>}<o:p></o:p></FONT></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><o:p><FONT color=#000000>&nbsp;</FONT></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp; </SPAN>#region</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><FONT color=#000000> IDisposable Members<o:p></o:p></FONT></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><o:p><FONT color=#000000>&nbsp;</FONT></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes"><FONT color=#000000>&nbsp;&nbsp; </FONT></SPAN><SPAN style="COLOR: blue">public</SPAN><FONT color=#000000> </FONT><SPAN style="COLOR: blue">void</SPAN><FONT color=#000000> Dispose()<o:p></o:p></FONT></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><FONT color=#000000><SPAN style="mso-spacerun: yes">&nbsp; </SPAN><SPAN style="mso-spacerun: yes">&nbsp;</SPAN>{<o:p></o:p></FONT></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><FONT color=#000000><SPAN style="mso-spacerun: yes">&nbsp; </SPAN><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;</SPAN>taskQueue.Dispose();<o:p></o:p></FONT></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><FONT color=#000000><SPAN style="mso-spacerun: yes">&nbsp; </SPAN><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;</SPAN>dispatcher.Dispose();<o:p></o:p></FONT></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><FONT color=#000000><SPAN style="mso-spacerun: yes">&nbsp; </SPAN><SPAN style="mso-spacerun: yes">&nbsp;</SPAN>}<o:p></o:p></FONT></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><o:p><FONT color=#000000>&nbsp;</FONT></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp; </SPAN><SPAN style="mso-spacerun: yes">&nbsp;</SPAN>#endregion<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><FONT color=#000000>}<o:p></o:p></FONT></SPAN></P>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><o:p><FONT color=#000000 size=3 face=Calibri>&nbsp;</FONT></o:p></P></SPAN><SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><FONT size=3 face=Calibri>There should be no magic in the code above. The code that you want to execute at the give frequency is&nbsp; put in the <SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #2b91af; FONT-SIZE: 10pt; mso-no-proof: yes; mso-bidi-language: AR-SA; mso-ansi-language: EN-US; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-fareast-language: EN-US">TimerDelegate <FONT size=3><FONT color=#000000 face=Calibri>instance , and thing work from there. Note, however, that this code does not guarantee that the delegate will be invoked on the tick as specified by the frequency: If your code in the <SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #2b91af; FONT-SIZE: 10pt; mso-no-proof: yes; mso-bidi-language: AR-SA; mso-ansi-language: EN-US; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-fareast-language: EN-US">TimerDelegate</SPAN> takes a long time to run, all that will happen is that there will be a certain number of ticks between invocations. For my usage, that is close enough. Now, finally, all the legalese: This code is provided as is. It may not be the most efficient, elegant or cool. If you have any questions, please let me know.</FONT></FONT></SPAN></FONT></P></SPAN>]]></content:encoded>
    </item>
    <item>
      <title>CCR and Hardware</title>
      <link>https://docs.microsoft.com/archive/blogs/thelever/ccr-and-hardware</link>
      <pubDate>Fri, 03 Oct 2008 20:31:00 GMT</pubDate>
      <dc:creator><![CDATA[thelever]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/thelever/2008/10/03/ccr-and-hardware/</guid>
      <description><![CDATA[It has been a while, but that does not mean that the cockpit project has been at a standstill. The...]]></description>
      <content:encoded><![CDATA[<P><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'">It has been a while, but that does not mean that the cockpit project has been at a standstill. The first step in terms of hardware was the arrival of an interface board. The card was this <A title="USB Interface Board" href="https://www.phidgets.com/products.php?product_id=1018" target=_blank mce_href="https://www.phidgets.com/products.php?product_id=1018">one</A>, but I guess it could have been several types of cards. One of the reasons I chose this card was that it has a managed API supplied with it. Again, that probably is also the case with other manufacturer's boards.<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p></SPAN></P>
<P><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'">So, it arrived. I immediately sat down to look at the managed API that works with this board. The API lends itself easily to use with CCR. Especially, part of it was almost a text book example of the Interleave arbiter. The story is this: When your app starts, you need to start an instance of a manager object. This manager object exposes a couple of events that notify interested parties when interface boards are attached or detached. Each of the interface boards that the manager manages, in turn has their own events when, say, input to the board or output from the board changes. This leads to the following Interleave arbiter groups:<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"><SPAN style="FONT-SIZE: 10pt; COLOR: #2b91af; FONT-FAMILY: 'Courier New'; mso-no-proof: yes; mso-bidi-language: HE">TeardownReceiverGroup</SPAN><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes; mso-bidi-language: HE"> failureOrCompletionGroup = <SPAN style="COLOR: blue">new</SPAN> <SPAN style="COLOR: #2b91af">TeardownReceiverGroup</SPAN>(<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes; mso-bidi-language: HE"><SPAN style="mso-spacerun: yes">&nbsp; </SPAN><SPAN style="COLOR: #2b91af">Arbiter</SPAN>.Receive&lt;<SPAN style="COLOR: #2b91af">ErrorEventArgs</SPAN>&gt;(<SPAN style="COLOR: blue">false</SPAN>, errorPort, error =&gt;<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes; mso-bidi-language: HE"><SPAN style="mso-spacerun: yes">&nbsp; </SPAN>{<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes; mso-bidi-language: HE"><SPAN style="mso-spacerun: yes">&nbsp; </SPAN><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;</SPAN><SPAN style="COLOR: gray">// Handle errors<o:p></o:p></SPAN></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes; mso-bidi-language: HE"><SPAN style="mso-spacerun: yes">&nbsp; </SPAN>}),<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes; mso-bidi-language: HE"><SPAN style="mso-spacerun: yes">&nbsp; </SPAN><SPAN style="COLOR: #2b91af">Arbiter</SPAN>.Receive&lt;<SPAN style="COLOR: #2b91af">TaskStop</SPAN>&gt;(<SPAN style="COLOR: blue">false</SPAN>, taskStopPort, taskStop =&gt;<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes; mso-bidi-language: HE"><SPAN style="mso-spacerun: yes">&nbsp; </SPAN>{<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes; mso-bidi-language: HE"><SPAN style="mso-spacerun: yes">&nbsp; </SPAN><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;</SPAN><SPAN style="COLOR: gray">// Handle normal shut down<o:p></o:p></SPAN></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes; mso-bidi-language: HE"><SPAN style="mso-spacerun: yes">&nbsp; </SPAN>}));<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"><SPAN style="FONT-SIZE: 10pt; COLOR: #2b91af; FONT-FAMILY: 'Courier New'; mso-no-proof: yes; mso-bidi-language: HE"><o:p>&nbsp;</o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"><SPAN style="FONT-SIZE: 10pt; COLOR: #2b91af; FONT-FAMILY: 'Courier New'; mso-no-proof: yes; mso-bidi-language: HE">ExclusiveReceiverGroup</SPAN><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes; mso-bidi-language: HE"> exclusiveGroup = <SPAN style="COLOR: blue">new</SPAN> <SPAN style="COLOR: #2b91af">ExclusiveReceiverGroup</SPAN>(<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes; mso-bidi-language: HE"><SPAN style="mso-spacerun: yes">&nbsp; </SPAN><SPAN style="COLOR: #2b91af">Arbiter</SPAN>.Receive&lt;<SPAN style="COLOR: #2b91af">AttachEventArgs</SPAN>&gt;(<SPAN style="COLOR: blue">true</SPAN>, attachPort, attachEventArgs =&gt;<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes; mso-bidi-language: HE"><SPAN style="mso-spacerun: yes">&nbsp; </SPAN>{<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes; mso-bidi-language: HE"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: gray">// Do what is needed to record that the manager has found a board</SPAN><o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes; mso-bidi-language: HE"><SPAN style="mso-spacerun: yes">&nbsp; </SPAN>}),<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes; mso-bidi-language: HE"><SPAN style="mso-spacerun: yes">&nbsp; </SPAN><SPAN style="COLOR: #2b91af">Arbiter</SPAN>.Receive&lt;<SPAN style="COLOR: #2b91af">DetachEventArgs</SPAN>&gt;(<SPAN style="COLOR: blue">true</SPAN>, detachPort, detachEventArgs =&gt;<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes; mso-bidi-language: HE"><SPAN style="mso-spacerun: yes">&nbsp; </SPAN>{<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes; mso-bidi-language: HE"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: gray">// Do what is needed to handle the fact that a board has been detached</SPAN><o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes; mso-bidi-language: HE"><SPAN style="mso-spacerun: yes">&nbsp; </SPAN>}));<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes; mso-bidi-language: HE"><o:p>&nbsp;</o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"><SPAN style="FONT-SIZE: 10pt; COLOR: #2b91af; FONT-FAMILY: 'Courier New'; mso-no-proof: yes; mso-bidi-language: HE">ConcurrentReceiverGroup</SPAN><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes; mso-bidi-language: HE"> concurrentGroup = <SPAN style="COLOR: blue">new</SPAN> <SPAN style="COLOR: #2b91af">ConcurrentReceiverGroup</SPAN>(<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes; mso-bidi-language: HE"><SPAN style="mso-spacerun: yes">&nbsp; </SPAN><SPAN style="COLOR: #2b91af">Arbiter</SPAN>.Receive&lt;<SPAN style="COLOR: #2b91af">OutputCommand</SPAN>&gt;(<SPAN style="COLOR: blue">true</SPAN>, outputCommandPort, outputCommand =&gt;<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes; mso-bidi-language: HE"><SPAN style="mso-spacerun: yes">&nbsp; </SPAN>{<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes; mso-bidi-language: HE"><SPAN style="mso-spacerun: yes">&nbsp; </SPAN><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;</SPAN><SPAN style="COLOR: gray">// Set an output port to true...</SPAN><o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes; mso-bidi-language: HE"><SPAN style="mso-spacerun: yes">&nbsp; </SPAN>}),<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes; mso-bidi-language: HE"><SPAN style="mso-spacerun: yes">&nbsp; </SPAN><SPAN style="COLOR: #2b91af">Arbiter</SPAN>.Receive&lt;<SPAN style="COLOR: #2b91af">InputChange</SPAN>&gt;(<SPAN style="COLOR: blue">true</SPAN>, interfaceKitPort, inputChange =&gt;<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes; mso-bidi-language: HE"><SPAN style="mso-spacerun: yes">&nbsp; </SPAN>{<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes; mso-bidi-language: HE"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: gray">// Handle an input change...</SPAN><o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes; mso-bidi-language: HE"><SPAN style="mso-spacerun: yes">&nbsp; </SPAN>}),<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes; mso-bidi-language: HE"><SPAN style="mso-spacerun: yes">&nbsp; </SPAN><SPAN style="COLOR: #2b91af">Arbiter</SPAN>.Receive&lt;<SPAN style="COLOR: #2b91af">OutputChange</SPAN>&gt;(<SPAN style="COLOR: blue">true</SPAN>, interfaceKitPort, outputChange =&gt;<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes; mso-bidi-language: HE"><SPAN style="mso-spacerun: yes">&nbsp; </SPAN>{<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes; mso-bidi-language: HE"><SPAN style="mso-spacerun: yes">&nbsp; </SPAN><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;</SPAN><SPAN style="COLOR: gray">// If you need to do some processing once the output has changed<o:p></o:p></SPAN></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes; mso-bidi-language: HE"><SPAN style="mso-spacerun: yes">&nbsp; </SPAN>}));<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes; mso-bidi-language: HE"><o:p>&nbsp;</o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"><SPAN style="FONT-SIZE: 10pt; COLOR: #2b91af; FONT-FAMILY: 'Courier New'; mso-no-proof: yes; mso-bidi-language: HE">Arbiter</SPAN><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes; mso-bidi-language: HE">.Activate(dispatcherQueue, <SPAN style="COLOR: #2b91af">Arbiter</SPAN>.Interleave(failureOrCompletionGroup, exclusiveGroup, concurrentGroup));<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes; mso-bidi-language: HE"><o:p>&nbsp;</o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"><SPAN style="FONT-SIZE: 10pt; COLOR: #2b91af; FONT-FAMILY: 'Courier New'; mso-no-proof: yes; mso-bidi-language: HE">ErrorEventArgs</SPAN><FONT face=Calibri size=3>, </FONT><SPAN style="FONT-SIZE: 10pt; COLOR: #2b91af; FONT-FAMILY: 'Courier New'; mso-no-proof: yes; mso-bidi-language: HE">AttachEventArgs</SPAN><FONT face=Calibri size=3> and </FONT><SPAN style="FONT-SIZE: 10pt; COLOR: #2b91af; FONT-FAMILY: 'Courier New'; mso-no-proof: yes; mso-bidi-language: HE">DetachEventArgs</SPAN><FONT face=Calibri size=3> are taken directly from the API of the board producer. </FONT><SPAN style="FONT-SIZE: 10pt; COLOR: #2b91af; FONT-FAMILY: 'Courier New'; mso-no-proof: yes; mso-bidi-language: HE">TaskStop</SPAN><FONT face=Calibri size=3> is just an empty class I created that I can post the port used in the second receiver in the </FONT><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes; mso-bidi-language: HE">failureOrCompletionGroup</SPAN><FONT face=Calibri size=3>. In the </FONT><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes; mso-bidi-language: HE">exclusiveGroup</SPAN><FONT face=Calibri size=3>, what I do is to keep track of the boards that are currently attached. The sweetness is that I can have a dictionary into which I insert entries in the </FONT><SPAN style="FONT-SIZE: 10pt; COLOR: #2b91af; FONT-FAMILY: 'Courier New'; mso-no-proof: yes; mso-bidi-language: HE">AttachEventArgs</SPAN><FONT face=Calibri size=3> receiver and from which I remove entries in the </FONT><SPAN style="FONT-SIZE: 10pt; COLOR: #2b91af; FONT-FAMILY: 'Courier New'; mso-no-proof: yes; mso-bidi-language: HE">DetachEventArgs</SPAN><FONT face=Calibri size=3> receiver totally without having to have synchronization primitives because the exclusive group guarantees </FONT><A class="" title="CCR ExclusiveGroup" href="https://msdn.microsoft.com/en-us/library/microsoft.ccr.core.exclusivereceivergroup.aspx" mce_href="https://msdn.microsoft.com/en-us/library/microsoft.ccr.core.exclusivereceivergroup.aspx"><FONT face=Calibri size=3>exclusiveness</FONT></A><FONT face=Calibri size=3> from other receivers in the group and from receivers in the concurrent group.</FONT></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"><o:p><FONT face=Calibri size=3>&nbsp;</FONT></o:p></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"><FONT face=Calibri size=3>The concurrent group is rather straightforward: I have a receiver for </FONT><SPAN style="FONT-SIZE: 10pt; COLOR: #2b91af; FONT-FAMILY: 'Courier New'; mso-no-proof: yes; mso-bidi-language: HE">OutputCommand</SPAN><FONT face=Calibri size=3> instances, which are commands sent by the application when it wants set an output to true. The </FONT><SPAN style="FONT-SIZE: 10pt; COLOR: #2b91af; FONT-FAMILY: 'Courier New'; mso-no-proof: yes; mso-bidi-language: HE">InputChange</SPAN><FONT face=Calibri size=3> receiver handles the case when an input has changed on a board, and the </FONT><SPAN style="FONT-SIZE: 10pt; COLOR: #2b91af; FONT-FAMILY: 'Courier New'; mso-no-proof: yes; mso-bidi-language: HE">OutputChange</SPAN><FONT face=Calibri size=3> receiver handles the feedback that comes back when an output has changed.</FONT></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"><o:p><FONT face=Calibri size=3>&nbsp;</FONT></o:p></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"><FONT face=Calibri size=3>Finally, all that is left to do is to activate the Interleave arbiter as shown in the last two lines of code.</FONT></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"><o:p><FONT face=Calibri size=3>&nbsp;</FONT></o:p></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"><FONT face=Calibri size=3>Isn’t CCR just too sweet to not use?</FONT></P>]]></content:encoded>
    </item>
    <item>
      <title>I have been contemplating...</title>
      <link>https://docs.microsoft.com/archive/blogs/thelever/i-have-been-contemplating</link>
      <pubDate>Sat, 02 Aug 2008 01:18:00 GMT</pubDate>
      <dc:creator><![CDATA[thelever]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/thelever/2008/08/02/i-have-been-contemplating/</guid>
      <description><![CDATA[I have finally made the decision! I am starting to realize... Or, stating to plan to realize... Or,...]]></description>
      <content:encoded><![CDATA[<P>I have finally made the decision! I am starting to realize... Or, stating to plan to realize... Or, calculating what it would cost to realize my long standing dream. Actually, the last hesitation here is not totally true. My point is that I have made a decision to start on a long term project that I have dreamed of doing for the longest time: <STRONG><EM>I want to build a cockpit replica for simulation purposes</EM></STRONG>! There! I have have now informed both my wife and Daniel about this. They both seem to support me in my decision. Daniel mostly by being very silent about it, but I am thinking I have as much approval from him as I can expect from a 21 month old kid.</P>
<P>I have been toying with the idea for many, many years but I have always been discouraged (or, read: prevented) by the cost of hardware/software&nbsp;that would live up to my expectations for such an undertaking.&nbsp;For a long time, there was really only one provider of&nbsp;software (this is discounting&nbsp;us -- Microsoft -- as we seem to be the platform for all these projects) and only one or two providers of hardware (not so much computer hardware, but panels and replicas) that could&nbsp;give you sort of building block approach to this. This has changed in the favor of the cockpit builder.</P>
<P>I think the&nbsp;final push came when I found out that we now offer a simulation platform in <A class="" title="Microsoft ESP Developer Center" href="https://msdn.microsoft.com/esp" target=_blank mce_href="https://msdn.microsoft.com/esp">ESP</A>. As an MSDN subscriber, I have access to the bits, and I have installed them at home. I am hoping that this will be a great way to combine at least two of my primary hobbies: Aviation and software design/development. Now that I have an [easy] way of writing software for the flight simulator myself, I can combine that with the drop in hardware prices and finally start to realize my dream. For instance, there should be nothing to prevent me from getting an IO card, from any of the many vendors that exist, and hooking that up to a stepper motor, write the software to read the variables in ESP&nbsp;et voíla we have a vertical speed indicator that is an actual piece of hardware and can be mounted in a frame that will eventually become a cockpit. This, of course, sounds much easier than it probably is -- especially considering that I am no mechanical/electronics whizz. I figure I will either learn along the way, or die trying.</P>
<P>So, now that this is out of the way, I guess there are only a few more questions to ask and answer: What type of cockpit will I be building? I am torn here. It is going to be a jet, and a short/medium haul. I am interested in the take-off and landings, not so much the cruise where most of the time is spent as an observer monitoring systems -- with that said, I guess the most obvious is short to medium haul. Within this genre, the battle is between Airbus A319/A320/A321 and Boeing 737NG (-600, -700, -800, -900). Trying to be totally unpolitical about it, I would argue that each plane has its advantages. I really like the philosophy behind Airbus, but at the same time, Boeing just hit the nail on the head with the 737. From a hardware (panels, switches etc) standpoint, I think the Airbus is probably easier -- just think of what it would take to make throttle levers for a B737 throttle quadrant with throttle levers that move in response to commands from the autopilot (or, MCP in Boeing speak), or dual linked control yokes that have "force feedback". On the other hand, I think it would be harder to write the software to control an Airbus because of the many laws that govern the Airbus (I can think of normal law, alternate law and direct law. Other laws may exist that I am not aware of yet).</P>
<P>Anyway, it is out now. This is the thing that I alluded to in one of my previous posts. Now, I am slowly starting to move along. Stay tuned.</P>]]></content:encoded>
    </item>
    <item>
      <title>A Little Trick to Ensure that Dispose is Called</title>
      <link>https://docs.microsoft.com/archive/blogs/thelever/a-little-trick-to-ensure-that-dispose-is-called</link>
      <pubDate>Sat, 19 Jul 2008 13:28:00 GMT</pubDate>
      <dc:creator><![CDATA[thelever]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/thelever/2008/07/19/a-little-trick-to-ensure-that-dispose-is-called/</guid>
      <description><![CDATA[Typically trying to avoid finalizers, there is one place* where they come in handy. That place is...]]></description>
      <content:encoded><![CDATA[<P>Typically trying to avoid finalizers, there is one place* where they come in handy. That place is making sure that all consumers of your objects call Dispose either explicitly or using the using construct. The trick is so simple -- there is no rocket science or otherwise involved.</P>
<P>Basically, the idea is that you in your class you have a Finalizer and the Dispose method. In your Dispose method, you do what you would normally do and you call <FONT color=#2b91af size=2><FONT color=#2b91af size=2>GC</FONT></FONT><FONT size=2>.SuppressFinalize(</FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>this</FONT></FONT><FONT size=2>). All of this happens within a <FONT color=#0000ff size=2><FONT color=#0000ff size=2>#if</FONT></FONT><FONT size=2> DEBUG ... <FONT color=#0000ff size=2><FONT color=#0000ff size=2>#endif.</P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"><SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes; mso-bidi-language: HE">#region</SPAN><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes; mso-bidi-language: HE"><FONT color=#000000> IDisposable Members<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p></FONT></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes; mso-bidi-language: HE"><SPAN style="mso-spacerun: yes"><FONT color=#000000>&nbsp; </FONT></SPAN><SPAN style="COLOR: blue">public</SPAN><FONT color=#000000> </FONT><SPAN style="COLOR: blue">void</SPAN><FONT color=#000000> Dispose()<o:p></o:p></FONT></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes; mso-bidi-language: HE"><FONT color=#000000><SPAN style="mso-spacerun: yes">&nbsp; </SPAN>{<o:p></o:p></FONT></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes; mso-bidi-language: HE"><FONT color=#000000><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>...<o:p></o:p></FONT></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"><SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes; mso-bidi-language: HE">#if</SPAN><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes; mso-bidi-language: HE"><FONT color=#000000> DEBUG<o:p></o:p></FONT></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes; mso-bidi-language: HE"><FONT color=#000000><SPAN style="mso-spacerun: yes">&nbsp; </SPAN><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;</SPAN></FONT><SPAN style="COLOR: #2b91af">GC</SPAN><FONT color=#000000>.SuppressFinalize(</FONT><SPAN style="COLOR: blue">this</SPAN><FONT color=#000000>);<o:p></o:p></FONT></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"><SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes; mso-bidi-language: HE">#endif<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes; mso-bidi-language: HE"><FONT color=#000000><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>...<o:p></o:p></FONT></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes; mso-bidi-language: HE"><FONT color=#000000><SPAN style="mso-spacerun: yes">&nbsp; </SPAN>}</FONT></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes; mso-bidi-language: HE"></SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes; mso-bidi-language: HE; mso-ansi-language: EN-US; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-fareast-language: EN-US">#endregion</SPAN>&nbsp;</P>
<P>&nbsp;<FONT color=#000000>Obviously, you can have more statements and instructions in your Dispose. </FONT></FONT></FONT>Your finalizer will look something like this:</P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"><SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes; mso-bidi-language: HE">#if</SPAN><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes; mso-bidi-language: HE"> DEBUG<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes; mso-bidi-language: HE"><SPAN style="mso-spacerun: yes">&nbsp; </SPAN>~DisposableClass()<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes; mso-bidi-language: HE"><SPAN style="mso-spacerun: yes">&nbsp; </SPAN>{<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes; mso-bidi-language: HE"><SPAN style="mso-spacerun: yes">&nbsp; </SPAN><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #2b91af">Debug</SPAN>.Assert(<SPAN style="COLOR: blue">false</SPAN>, <SPAN style="COLOR: red">"Disposable object not disposed"</SPAN>);<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes; mso-bidi-language: HE"><SPAN style="mso-spacerun: yes">&nbsp; </SPAN>}</SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes; mso-bidi-language: HE"></SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes; mso-bidi-language: HE; mso-ansi-language: EN-US; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-fareast-language: EN-US">#endif</SPAN></P>
<P>Of course, the magic that makes this work is that if Dispose is ever invoked, the finalizer is never invoked. Conversely, if the finalizer is&nbsp;invoked, then Dispose was not. This is a great way to ensure that your disposable objects are actively disposed of and if they are not, then you are made aware of that fact with a loud fanfare.</P>
<P>I am imagining that you could probably do some more fancy tracking by recording the stack frame of the allocation and display that when your finalizer asserts false. I will leave this as an exercise for the reader**.</P></FONT></FONT>
<P>* There may be others, but with SafeHandle I can't think of many places where you would need to keep explicit track of unmanaged resources.</P>
<P>** Through all my years in university, I always hated when professors would leave interesting points as&nbsp;exercises left to the reader. If you are trying to drive a point, make sure that it is not left to chance if you get it across or not. However, I have waited many&nbsp;years to use that same sentence, so here it is.&nbsp;</P>]]></content:encoded>
    </item>
    <item>
      <title>This time it is... Thomas the Train</title>
      <link>https://docs.microsoft.com/archive/blogs/thelever/this-time-it-is-thomas-the-train</link>
      <pubDate>Fri, 18 Jul 2008 01:23:00 GMT</pubDate>
      <dc:creator><![CDATA[thelever]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/thelever/2008/07/18/this-time-it-is-thomas-the-train/</guid>
      <description><![CDATA[Just a small note as I am expanding the list of TV shows that can end up getting on your nerves when...]]></description>
      <content:encoded><![CDATA[<P>Just a small note as I am expanding the list of TV shows that can end up getting on your nerves when your 20 month old son insists on watching them on repeat: Thomas and Friends can get pretty hairy too. Once again, I am happy about the combination of CCR and WCF. Now I just need to get FSX into the mix.</P>
<P>&nbsp;Stay tuned (just not to Thomas and Friends).</P>]]></content:encoded>
    </item>
  </channel>
</rss>