<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:pingback="http://madskills.com/public/xml/rss/module/pingback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" version="2.0">
  <channel>
    <title>Rockford Lhotka - Workflow</title>
    <link>http://www.lhotka.net/weblog/</link>
    <description>Creator of the CSLA .NET framework</description>
    <language>en-us</language>
    <copyright>Marimer LLC</copyright>
    <lastBuildDate>Sat, 01 Nov 2008 01:10:16 GMT</lastBuildDate>
    <generator>newtelligence dasBlog 2.0.7226.0</generator>
    <managingEditor>rocky@lhotka.net</managingEditor>
    <webMaster>rocky@lhotka.net</webMaster>
    <item>
      <trackback:ping>http://www.lhotka.net/weblog/Trackback.aspx?guid=c76d5eb6-ad0e-48fb-abee-28e81736cdcf</trackback:ping>
      <pingback:server>http://www.lhotka.net/weblog/pingback.aspx</pingback:server>
      <pingback:target>http://www.lhotka.net/weblog/PermaLink,guid,c76d5eb6-ad0e-48fb-abee-28e81736cdcf.aspx</pingback:target>
      <dc:creator>Rockford Lhotka</dc:creator>
      <wfw:comment>http://www.lhotka.net/weblog/CommentView,guid,c76d5eb6-ad0e-48fb-abee-28e81736cdcf.aspx</wfw:comment>
      <wfw:commentRss>http://www.lhotka.net/weblog/SyndicationService.asmx/GetEntryCommentsRss?guid=c76d5eb6-ad0e-48fb-abee-28e81736cdcf</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
PDC 2008 was a lot of fun - a big show, with lots of announcements, lots of sessions
and some thought-provoking content. I thought I'd through out a few observations.
Not really conclusions, as those take time and reflection, so just some observations.
</p>
        <p>
          <strong>Windows Azure</strong>, the operating system for the cloud, is intriguing.
For a first run at this, the technology seems surprisingly complete and contains a
pretty reasonable set of features. I can easily see how web sites, XML services and
both data-centric and compute-centric processing could be built for this platform.
For that matter, it looks like it would be perhaps a week's work to get my web site
ported over to run completely in Azure.
</p>
        <p>
The real question is whether that would even make sense, and <em>that</em> comes down
to the value proposition. One big component of value is price. Like anyone else, I
pay a certain amount to run my web site. Electricity, bandwidth, support time, hardware
costs, software costs, etc. I've never really sorted out an exact cost, but it isn't
real high on a per-month basis. And I could host on any number of .NET-friendly hosting
services that have been around for years, and some of them are pretty inexpensive.
So the question becomes whether Azure will be priced in such a way that it is attractive
to me. If so, I'm excited about Azure!! If not, then I really don't care about Azure.
</p>
        <p>
I suspect most attendees went through a similar thought process. If Microsoft prices
Azure for "the enterprise" then 90% of the developers in the world simply don't care
about Azure. But if Microsoft prices Azure for small to mid-size businesses, and for
the very small players (like me) then 90% of the developers in the world should (I
think) really be looking at this technology
</p>
        <p>
          <strong>Windows 7 </strong>looks good to me. After the Tuesday keynote I was ready
to install it <em>now</em>. As time goes by the urgency has faded a bit - Vista has
stabilized nicely over the past 6-8 months and I really like it now. Windows 7 has
some nice-sounding new features though. Probably the single biggest one is reduced
system resource requirements. If Microsoft can deliver on that part of the promise
I'll be totally thrilled. Though I really <em>do</em> want multi-monitor RDP and the
ability to manage, mount (and even boot from) vhd files directly from the host OS.
</p>
        <p>
In talking to friends of mine that work at Microsoft, my level of confidence in W7
is quite high. A couple of them have been running it for some time now, and while
it is clearly pre-beta, they have found it to be a very satisfying experience. When
I get back from all my travels I do think I'll have to buy a spare HD for my laptop
and give it a try myself.
</p>
        <p>
The <strong>Oslo modeling tools</strong> are also interesting, though they are more
future-looking. Realistically this idea of model-driven development will require a
major shift in how our industry thinks about and approaches <a href="http://magenic.com/Services/CustomSoftwareDevelopment.aspx">custom
software development</a>. Such a massive shift will take many years to occur, regardless
of whether the technology is there to enable it. It is admirable that Microsoft is
taking such a gamble - building a set of tools and technologies for something that
might become acceptable to developers in the murky future. Their gamble will pay off
if we collectively decide that the world of 3GL development really is at an end and
that we need to move to higher levels of abstraction. Of course we could decide to
stick with what has (and hasn't) worked for 30+ years, in which case modeling tools
will go the way of CASE.
</p>
        <p>
But even if some of the really forward-looking modeling ideas never become palatable,
many of the things Microsoft is doing to support modeling are immediately useful.
Enhancements to Windows Workflow are a prime example, as is the M language. I've hard
a hard time getting excited about WF, because it has felt like a graphical way to
do FORTRAN. But some of the enhancements to WF directly address my primary concerns,
and I can see myself getting much more interested in WF in the relatively near future.
And the ability of the M language to define other languages (create DSLs), where I
can create my own output generator to create whatever I need - now <em>that</em> is
really, really cool!
</p>
        <p>
Once I get done with my book and all my fall travel, you can bet I'll be exploring
the use of M to create a specialized language to simplify the creation of CSLA .NET
business classes :)
</p>
        <p>
There were numerous talks about <strong>.NET 4.0</strong> and the future of C# and
VB. 
</p>
        <p>
Probably the single biggest thing on the language front is that Microsoft has finally
decided to sync VB and C# so they have feature parity. Enough of this back-and-forth
with different features, the languages will now just move forward together. A few
years ago I would have argued against this, because competition breeds innovation.
But today I don't think it matters, because the innovation is coming from F#, Ruby,
Python and various other languages and initiatives. Both VB and C# have such massive
pre-existing code-bases (all the code we've written) that they can't move rapidly
or explore radical ideas - while some of these other languages are more free to do
just that.
</p>
        <p>
The framework itself has all sorts of changes and improvements. I spent less time
looking at this than at Azure and Oslo though, so I honestly just don't have a lot
to say on it right now. I look at .NET 4.0 and Visual Studio 2010 as being more tactical
- things I'll spend a lot of time on over the next few months anyway - so I didn't
see so much need to spend my time on it during PDC.
</p>
        <p>
Finally, there were announcements around <strong>Silverlight and WPF</strong>. If
anyone doubts that XAML is the future of the UI on Windows and (to some degree) the
web, now is the time to wake up and smell the coffee. I'm obviously convinced Silverlight
is going to rapidly become the default technology for building business apps, with
WPF and Ajax as fallback positions, and everything at the PDC simply reinforced this
viewpoint.
</p>
        <p>
The new Silverlight and WPF toolkits provide better parity between the two XAML dialects,
and show how aggressively Microsoft is working to achieve true parity.
</p>
        <p>
But more important is the Silverlight intersection with Azure and Live Mesh. The fact
that I can build <em>smart client apps</em> that totally host in Azure or the Mesh
is compelling, and puts Silverlight a notch above WPF in terms of being the desired
start-point for app development. Yes, I really like WPF, but even if it can host in
Azure it probably won't host in Mesh, and in neither case will it be as clean or seamless.
</p>
        <p>
So while I fully appreciate that WPF is good for that small percentage of business
apps that need access to DirectX or rich client-side resources, I still think <em>most</em> business
apps will work just fine with access to the monitor/keyboard/mouse/memory/CPU provided
by Silverlight. 
</p>
        <p>
A couple people asked why I think Silverlight is better than Ajax. To me this is drop-dead
simple. I can write a class in C# or VB that runs on the client in Silverlight. I
can write real smart client applications that run in the browser. And I can run that <em>exact
same code</em> on the server too. So I can give the user a very interactive experience,
and then re-run that same code on the server because I don't trust the client.
</p>
        <p>
To do that in Ajax you'd either have to write your code twice (in C# and in Javascript),
or you'd have to do tons of server calls to simulate the interactivity provided by
Silverlight - and that obviously won't scale nearly the same as the more correct Silverlight
solution.
</p>
        <p>
To me it is a no-brainer - Ajax loses when it comes to building interactive business
apps like order entry screens, customer maintenance screens, etc.
</p>
        <p>
That's not to say Ajax has no home. The web and browser world is really good at displaying
data, and Ajax makes data display more interesting that simple HTML. I strongly suspect
that most "Silverlight" apps will make heavy use of HTML/Ajax for data display, but
I just can't see why anyone would willingly choose to create data entry forms or other
interactive parts of their app outside of Silverlight.
</p>
        <p>
And that wraps up my on-the-flight-home summary of thoughts about PDC. 
</p>
        <p>
Next week I'm speaking at the Patterns and Practices Summit in Redmond, and then I'll
be at Tech Ed EMEA in Barcelona. I'm doing a number of sessions at both events, but
what's cool is that at each event I'm doing a talk specifically about CSLA .NET for
Silverlight. And in December I'll be at VS Live in Dallas, where I'll also give a
talk directly on using CSLA .NET.
</p>
        <img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=c76d5eb6-ad0e-48fb-abee-28e81736cdcf" />
      </body>
      <title>Thoughts on PDC 2008</title>
      <guid isPermaLink="false">http://www.lhotka.net/weblog/PermaLink,guid,c76d5eb6-ad0e-48fb-abee-28e81736cdcf.aspx</guid>
      <link>http://www.lhotka.net/weblog/ThoughtsOnPDC2008.aspx</link>
      <pubDate>Sat, 01 Nov 2008 01:10:16 GMT</pubDate>
      <description>&lt;p&gt;
PDC 2008 was a lot of fun - a big show, with lots of announcements, lots of sessions
and some thought-provoking content. I thought I'd through out a few observations.
Not really conclusions, as those take time and reflection, so just some observations.
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Windows Azure&lt;/strong&gt;, the operating system for the cloud, is intriguing.
For a first run at this, the technology seems surprisingly complete and contains a
pretty reasonable set of features. I can easily see how web sites, XML services and
both data-centric and compute-centric processing could be built for this platform.
For that matter, it looks like it would be perhaps a week's work to get my web site
ported over to run completely in Azure.
&lt;/p&gt;
&lt;p&gt;
The real question is whether that would even make sense, and &lt;em&gt;that&lt;/em&gt; comes down
to the value proposition. One big component of value is price. Like anyone else, I
pay a certain amount to run my web site. Electricity, bandwidth, support time, hardware
costs, software costs, etc. I've never really sorted out an exact cost, but it isn't
real high on a per-month basis. And I could host on any number of .NET-friendly hosting
services that have been around for years, and some of them are pretty inexpensive.
So the question becomes whether Azure will be priced in such a way that it is attractive
to me. If so, I'm excited about Azure!! If not, then I really don't care about Azure.
&lt;/p&gt;
&lt;p&gt;
I suspect most attendees went through a similar thought process. If Microsoft prices
Azure for "the enterprise" then 90% of the developers in the world simply don't care
about Azure. But if Microsoft prices Azure for small to mid-size businesses, and for
the very small players (like me) then 90% of the developers in the world should (I
think) really be looking at this technology
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Windows 7 &lt;/strong&gt;looks good to me. After the Tuesday keynote I was ready
to install it &lt;em&gt;now&lt;/em&gt;. As time goes by the urgency has faded a bit - Vista has
stabilized nicely over the past 6-8 months and I really like it now. Windows 7 has
some nice-sounding new features though. Probably the single biggest one is reduced
system resource requirements. If Microsoft can deliver on that part of the promise
I'll be totally thrilled. Though I really &lt;em&gt;do&lt;/em&gt; want multi-monitor RDP and the
ability to manage, mount (and even boot from) vhd files directly from the host OS.
&lt;/p&gt;
&lt;p&gt;
In talking to friends of mine that work at Microsoft, my level of confidence in W7
is quite high. A couple of them have been running it for some time now, and while
it is clearly pre-beta, they have found it to be a very satisfying experience. When
I get back from all my travels I do think I'll have to buy a spare HD for my laptop
and give it a try myself.
&lt;/p&gt;
&lt;p&gt;
The &lt;strong&gt;Oslo modeling tools&lt;/strong&gt; are also interesting, though they are more
future-looking. Realistically this idea of model-driven development will require a
major shift in how our industry thinks about and approaches &lt;a href="http://magenic.com/Services/CustomSoftwareDevelopment.aspx"&gt;custom
software development&lt;/a&gt;. Such a massive shift will take many years to occur, regardless
of whether the technology is there to enable it. It is admirable that Microsoft is
taking such a gamble - building a set of tools and technologies for something that
might become acceptable to developers in the murky future. Their gamble will pay off
if we collectively decide that the world of 3GL development really is at an end and
that we need to move to higher levels of abstraction. Of course we could decide to
stick with what has (and hasn't) worked for 30+ years, in which case modeling tools
will go the way of CASE.
&lt;/p&gt;
&lt;p&gt;
But even if some of the really forward-looking modeling ideas never become palatable,
many of the things Microsoft is doing to support modeling are immediately useful.
Enhancements to Windows Workflow are a prime example, as is the M language. I've hard
a hard time getting excited about WF, because it has felt like a graphical way to
do FORTRAN. But some of the enhancements to WF directly address my primary concerns,
and I can see myself getting much more interested in WF in the relatively near future.
And the ability of the M language to define other languages (create DSLs), where I
can create my own output generator to create whatever I need - now &lt;em&gt;that&lt;/em&gt; is
really, really cool!
&lt;/p&gt;
&lt;p&gt;
Once I get done with my book and all my fall travel, you can bet I'll be exploring
the use of M to create a specialized language to simplify the creation of CSLA .NET
business classes :)
&lt;/p&gt;
&lt;p&gt;
There were numerous talks about &lt;strong&gt;.NET 4.0&lt;/strong&gt; and the future of C# and
VB. 
&lt;/p&gt;
&lt;p&gt;
Probably the single biggest thing on the language front is that Microsoft has finally
decided to sync VB and C# so they have feature parity. Enough of this back-and-forth
with different features, the languages will now just move forward together. A few
years ago I would have argued against this, because competition breeds innovation.
But today I don't think it matters, because the innovation is coming from F#, Ruby,
Python and various other languages and initiatives. Both VB and C# have such massive
pre-existing code-bases (all the code we've written) that they can't move rapidly
or explore radical ideas - while some of these other languages are more free to do
just that.
&lt;/p&gt;
&lt;p&gt;
The framework itself has all sorts of changes and improvements. I spent less time
looking at this than at Azure and Oslo though, so I honestly just don't have a lot
to say on it right now. I look at .NET 4.0 and Visual Studio 2010 as being more tactical
- things I'll spend a lot of time on over the next few months anyway - so I didn't
see so much need to spend my time on it during PDC.
&lt;/p&gt;
&lt;p&gt;
Finally, there were announcements around &lt;strong&gt;Silverlight and WPF&lt;/strong&gt;. If
anyone doubts that XAML is the future of the UI on Windows and (to some degree) the
web, now is the time to wake up and smell the coffee. I'm obviously convinced Silverlight
is going to rapidly become the default technology for building business apps, with
WPF and Ajax as fallback positions, and everything at the PDC simply reinforced this
viewpoint.
&lt;/p&gt;
&lt;p&gt;
The new Silverlight and WPF toolkits provide better parity between the two XAML dialects,
and show how aggressively Microsoft is working to achieve true parity.
&lt;/p&gt;
&lt;p&gt;
But more important is the Silverlight intersection with Azure and Live Mesh. The fact
that I can build &lt;em&gt;smart client apps&lt;/em&gt; that totally host in Azure or the Mesh
is compelling, and puts Silverlight a notch above WPF in terms of being the desired
start-point for app development. Yes, I really like WPF, but even if it can host in
Azure it probably won't host in Mesh, and in neither case will it be as clean or seamless.
&lt;/p&gt;
&lt;p&gt;
So while I fully appreciate that WPF is good for that small percentage of business
apps that need access to DirectX or rich client-side resources, I still think &lt;em&gt;most&lt;/em&gt; business
apps will work just fine with access to the monitor/keyboard/mouse/memory/CPU provided
by Silverlight. 
&lt;/p&gt;
&lt;p&gt;
A couple people asked why I think Silverlight is better than Ajax. To me this is drop-dead
simple. I can write a class in C# or VB that runs on the client in Silverlight. I
can write real smart client applications that run in the browser. And I can run that &lt;em&gt;exact
same code&lt;/em&gt; on the server too. So I can give the user a very interactive experience,
and then re-run that same code on the server because I don't trust the client.
&lt;/p&gt;
&lt;p&gt;
To do that in Ajax you'd either have to write your code twice (in C# and in Javascript),
or you'd have to do tons of server calls to simulate the interactivity provided by
Silverlight - and that obviously won't scale nearly the same as the more correct Silverlight
solution.
&lt;/p&gt;
&lt;p&gt;
To me it is a no-brainer - Ajax loses when it comes to building interactive business
apps like order entry screens, customer maintenance screens, etc.
&lt;/p&gt;
&lt;p&gt;
That's not to say Ajax has no home. The web and browser world is really good at displaying
data, and Ajax makes data display more interesting that simple HTML. I strongly suspect
that most "Silverlight" apps will make heavy use of HTML/Ajax for data display, but
I just can't see why anyone would willingly choose to create data entry forms or other
interactive parts of their app outside of Silverlight.
&lt;/p&gt;
&lt;p&gt;
And that wraps up my on-the-flight-home summary of thoughts about PDC. 
&lt;/p&gt;
&lt;p&gt;
Next week I'm speaking at the Patterns and Practices Summit in Redmond, and then I'll
be at Tech Ed EMEA in Barcelona. I'm doing a number of sessions at both events, but
what's cool is that at each event I'm doing a talk specifically about CSLA .NET for
Silverlight. And in December I'll be at VS Live in Dallas, where I'll also give a
talk directly on using CSLA .NET.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=c76d5eb6-ad0e-48fb-abee-28e81736cdcf" /&gt;</description>
      <comments>http://www.lhotka.net/weblog/CommentView,guid,c76d5eb6-ad0e-48fb-abee-28e81736cdcf.aspx</comments>
      <category>Microsoft .NET</category>
      <category>Silverlight</category>
      <category>WCF</category>
      <category>Workflow</category>
      <category>WPF</category>
    </item>
    <item>
      <trackback:ping>http://www.lhotka.net/weblog/Trackback.aspx?guid=bcd4e249-8203-40e2-bced-2978423fd38b</trackback:ping>
      <pingback:server>http://www.lhotka.net/weblog/pingback.aspx</pingback:server>
      <pingback:target>http://www.lhotka.net/weblog/PermaLink,guid,bcd4e249-8203-40e2-bced-2978423fd38b.aspx</pingback:target>
      <dc:creator>Rockford Lhotka</dc:creator>
      <wfw:comment>http://www.lhotka.net/weblog/CommentView,guid,bcd4e249-8203-40e2-bced-2978423fd38b.aspx</wfw:comment>
      <wfw:commentRss>http://www.lhotka.net/weblog/SyndicationService.asmx/GetEntryCommentsRss?guid=bcd4e249-8203-40e2-bced-2978423fd38b</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <div style="FLOAT: right; MARGIN: 5px 15px 5px 5px">
          <a href="http://store.lhotka.net">
            <img src="http://www.lhotka.net/images/csla30cscover-165.jpg" border="0" />
          </a>
        </div>
        <p>
CSLA .NET version 3.0 adds support for Microsoft .NET 3.0 features. This ~120
page ebook covers how to use these new capabilities: 
</p>
        <p>
        </p>
        <ul>
          <li>
Windows Presentation Foundation (WPF) 
<ul><li>
Creating WPF forms using business objects 
</li><li>
Using the new controls in the Csla.Wpf namespace 
<ul><li>
CslaDataProvider 
</li><li>
Validator 
</li><li>
Authorizer 
</li><li>
ObjectStatus 
</li><li>
IdentityConverter</li></ul></li><li>
Maximizing XAML and minimizing C#/VB code</li></ul></li>
          <li>
Windows Communication Foundation (WCF) 
<ul><li>
Using the new WCF data portal channel to seamlessly upgrade from Remoting, Web services
or Enterprise Services 
</li><li>
Building WCF services using business objects 
</li><li>
Applying WCF security to encrypt data on the wire 
</li><li>
Sending username/password credentials to a WCF service 
<ul><li>
Including use of the new Csla.Security.PrincipalCache class</li></ul></li><li>
Using the DataContract attribute instead of the Serializable attribute</li></ul></li>
          <li>
Windows Workflow Foundation (WF) 
<ul><li>
Creating activities using business objects 
</li><li>
Invoking a workflow from a business object 
</li><li>
Using the WorkflowManager class in the Csla.Workflow namespace</li></ul></li>
        </ul>
        <p>
Version 3.0 is an <em>additive update</em>, meaning that you only need to use the
.NET 3.0 features if you are using .NET 3.0. CSLA .NET 3.0 <em>is useful <a href="http://www.lhotka.net/Article.aspx?area=4&amp;id=ac20fe4c-6afc-4176-bcb4-d74b5a370356">for
people using .NET 2.0</a>!!</em> These features include:
</p>
        <ul>
          <li>
Enhancements to the validation subsystem 
<ul><li>
Friendly names for properties 
</li><li>
Better null handling in the RegExMatch rule method 
</li><li>
New StringMinLength rule method 
</li><li>
Help for code generation through the DecoratedRuleArgs class</li></ul></li>
          <li>
Data binding issues 
<ul><li>
Fixed numerous bugs in BusinessListBase to improve data binding behavior 
</li><li>
Throw exception when edit levels get out of sync, making debugging easier 
</li><li>
N-level undo changed to provide parity with Windows Forms data binding requirements</li></ul></li>
          <li>
AutoCloneOnUpdate 
<ul><li>
Automatically clone objects when Save() is called, but only when data portal is local</li></ul></li>
          <li>
Enhancements to the authorization subsystem 
<ul><li>
CanExecuteMethod() allows authorization for arbitrary methods</li></ul></li>
        </ul>
        <p>
CSLA .NET 3.0 includes numerous bug fixes and some feature enhancements that benefit
everyone. If you are using version 2.0 or 2.1, you should consider upgrading to 3.0
to gain these benefits, even if you aren't using .NET 3.0.
</p>
        <p>
See the change logs for <a href="http://www.lhotka.net/Article.aspx?area=4&amp;id=0c94aa82-b975-455b-a0c5-f4f7196a2408">version
3.0</a>, <a href="http://www.lhotka.net/Article.aspx?area=4&amp;id=4534c39c-c5d8-4553-88af-bdc1c8149cbc">version
3.0.1</a> and <a href="http://www.lhotka.net/Article.aspx?area=4&amp;id=7360998d-d842-49f6-b1f0-a21b517798e3">version
3.0.2</a> for a more detailed list of changes.
</p>
        <p>
          <em>Using CSLA .NET 3.0</em> is completely focused on how to use the new features
in version 3.0. The book does not detail the internal changes to CSLA .NET itself,
so all ~120 pages help you use the enhancements added since version 2.1.
</p>
        <p>
          <font size="5">Get the book at </font>
          <a href="http://store.lhotka.net/">
            <font size="5">store.lhotka.net</font>
          </a>
          <font size="5">. 
<br />
(C# available now, VB available in early October)</font>
        </p>
        <p>
Download the 3.0.2 code from the <a href="http://www.lhotka.net/cslanet/download.aspx">CSLA
.NET download page</a>.
</p>
        <img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=bcd4e249-8203-40e2-bced-2978423fd38b" />
      </body>
      <title>Using CSLA .NET 3.0 ebook available (and CSLA .NET version 3.0.2)</title>
      <guid isPermaLink="false">http://www.lhotka.net/weblog/PermaLink,guid,bcd4e249-8203-40e2-bced-2978423fd38b.aspx</guid>
      <link>http://www.lhotka.net/weblog/UsingCSLANET30EbookAvailableAndCSLANETVersion302.aspx</link>
      <pubDate>Fri, 28 Sep 2007 21:21:26 GMT</pubDate>
      <description>&lt;div style="FLOAT: right; MARGIN: 5px 15px 5px 5px"&gt;&lt;a href="http://store.lhotka.net"&gt;&lt;img src="http://www.lhotka.net/images/csla30cscover-165.jpg" border=0&gt;&lt;/a&gt; 
&lt;/div&gt;
&lt;p&gt;
CSLA .NET version&amp;nbsp;3.0 adds support for Microsoft .NET 3.0 features. This ~120
page ebook covers how to use these new capabilities: 
&lt;/p&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
Windows Presentation Foundation (WPF) 
&lt;ul&gt;
&lt;li&gt;
Creating&amp;nbsp;WPF forms using business objects 
&lt;li&gt;
Using the new controls in the Csla.Wpf namespace 
&lt;ul&gt;
&lt;li&gt;
CslaDataProvider 
&lt;li&gt;
Validator 
&lt;li&gt;
Authorizer 
&lt;li&gt;
ObjectStatus 
&lt;li&gt;
IdentityConverter&lt;/li&gt;
&lt;/ul&gt;
&lt;li&gt;
Maximizing XAML and minimizing C#/VB code&lt;/li&gt;
&lt;/ul&gt;
&lt;li&gt;
Windows Communication Foundation (WCF) 
&lt;ul&gt;
&lt;li&gt;
Using the new WCF data portal channel to seamlessly upgrade from Remoting, Web services
or Enterprise Services 
&lt;li&gt;
Building WCF services using business objects 
&lt;li&gt;
Applying WCF security to encrypt data on the wire 
&lt;li&gt;
Sending username/password credentials to a WCF service 
&lt;ul&gt;
&lt;li&gt;
Including use of the new Csla.Security.PrincipalCache class&lt;/li&gt;
&lt;/ul&gt;
&lt;li&gt;
Using the DataContract attribute instead of the Serializable attribute&lt;/li&gt;
&lt;/ul&gt;
&lt;li&gt;
Windows Workflow Foundation (WF) 
&lt;ul&gt;
&lt;li&gt;
Creating activities using business objects 
&lt;li&gt;
Invoking a workflow from a business object 
&lt;li&gt;
Using the WorkflowManager class in the Csla.Workflow namespace&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
Version 3.0 is an &lt;em&gt;additive update&lt;/em&gt;, meaning that you only need to use the
.NET 3.0 features if you are using .NET 3.0. CSLA .NET 3.0 &lt;em&gt;is useful &lt;a href="http://www.lhotka.net/Article.aspx?area=4&amp;amp;id=ac20fe4c-6afc-4176-bcb4-d74b5a370356"&gt;for
people using .NET 2.0&lt;/a&gt;!!&lt;/em&gt; These features include:
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
Enhancements to the validation subsystem 
&lt;ul&gt;
&lt;li&gt;
Friendly names for properties 
&lt;li&gt;
Better null handling in the RegExMatch rule method 
&lt;li&gt;
New StringMinLength rule method 
&lt;li&gt;
Help for code generation through the DecoratedRuleArgs class&lt;/li&gt;
&lt;/ul&gt;
&lt;li&gt;
Data binding issues 
&lt;ul&gt;
&lt;li&gt;
Fixed numerous bugs in BusinessListBase to improve data binding behavior 
&lt;li&gt;
Throw exception when edit levels get out of sync, making debugging easier 
&lt;li&gt;
N-level undo changed to provide parity with Windows Forms data binding requirements&lt;/li&gt;
&lt;/ul&gt;
&lt;li&gt;
AutoCloneOnUpdate 
&lt;ul&gt;
&lt;li&gt;
Automatically clone objects when Save() is called, but only when data portal is local&lt;/li&gt;
&lt;/ul&gt;
&lt;li&gt;
Enhancements to the authorization subsystem 
&lt;ul&gt;
&lt;li&gt;
CanExecuteMethod() allows authorization for arbitrary methods&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
CSLA .NET 3.0 includes numerous bug fixes and some feature enhancements that benefit
everyone. If you are using version 2.0 or 2.1, you should consider upgrading to 3.0
to gain these benefits, even if you aren't using .NET 3.0.
&lt;/p&gt;
&lt;p&gt;
See the change logs for &lt;a href="http://www.lhotka.net/Article.aspx?area=4&amp;amp;id=0c94aa82-b975-455b-a0c5-f4f7196a2408"&gt;version
3.0&lt;/a&gt;, &lt;a href="http://www.lhotka.net/Article.aspx?area=4&amp;amp;id=4534c39c-c5d8-4553-88af-bdc1c8149cbc"&gt;version
3.0.1&lt;/a&gt; and &lt;a href="http://www.lhotka.net/Article.aspx?area=4&amp;amp;id=7360998d-d842-49f6-b1f0-a21b517798e3"&gt;version
3.0.2&lt;/a&gt; for a more detailed list of changes.
&lt;/p&gt;
&lt;p&gt;
&lt;em&gt;Using CSLA .NET 3.0&lt;/em&gt; is completely focused on how to use the new features
in version 3.0. The book does not detail the internal changes to CSLA .NET itself,
so all ~120 pages help you use the enhancements added since version 2.1.
&lt;/p&gt;
&lt;p&gt;
&lt;font size=5&gt;Get the book at &lt;/font&gt;&lt;a href="http://store.lhotka.net/"&gt;&lt;font size=5&gt;store.lhotka.net&lt;/font&gt;&lt;/a&gt;&lt;font size=5&gt;. 
&lt;br&gt;
(C# available now, VB available in early October)&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
Download the 3.0.2 code from the &lt;a href="http://www.lhotka.net/cslanet/download.aspx"&gt;CSLA
.NET download page&lt;/a&gt;.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=bcd4e249-8203-40e2-bced-2978423fd38b" /&gt;</description>
      <comments>http://www.lhotka.net/weblog/CommentView,guid,bcd4e249-8203-40e2-bced-2978423fd38b.aspx</comments>
      <category>Books</category>
      <category>CSLA .NET</category>
      <category>WCF</category>
      <category>Workflow</category>
      <category>WPF</category>
    </item>
    <item>
      <trackback:ping>http://www.lhotka.net/weblog/Trackback.aspx?guid=945f9740-c5fb-4c34-8207-b4ca00e6c21c</trackback:ping>
      <pingback:server>http://www.lhotka.net/weblog/pingback.aspx</pingback:server>
      <pingback:target>http://www.lhotka.net/weblog/PermaLink,guid,945f9740-c5fb-4c34-8207-b4ca00e6c21c.aspx</pingback:target>
      <dc:creator>Rockford Lhotka</dc:creator>
      <wfw:comment>http://www.lhotka.net/weblog/CommentView,guid,945f9740-c5fb-4c34-8207-b4ca00e6c21c.aspx</wfw:comment>
      <wfw:commentRss>http://www.lhotka.net/weblog/SyndicationService.asmx/GetEntryCommentsRss?guid=945f9740-c5fb-4c34-8207-b4ca00e6c21c</wfw:commentRss>
      <title>Executing a workflow</title>
      <guid isPermaLink="false">http://www.lhotka.net/weblog/PermaLink,guid,945f9740-c5fb-4c34-8207-b4ca00e6c21c.aspx</guid>
      <link>http://www.lhotka.net/weblog/ExecutingAWorkflow.aspx</link>
      <pubDate>Wed, 01 Aug 2007 22:15:26 GMT</pubDate>
      <description>&lt;p&gt;
I wrote the following for the &lt;em&gt;Using CSLA .NET 3.0&lt;/em&gt; ebook, but I don't think
I'm going to use it now, because I've wrapped most of this into a new class in CSLA
.NET. Rather than letting this go to waste though, I thought I'd post it here. Remember
that it is just draft content, so it may have typos or errors, but perhaps it will
be useful to someone:
&lt;/p&gt;
&lt;h2 style="MARGIN: 12pt 0in 3pt"&gt;&lt;em&gt;&lt;font face=Arial color=#000000&gt;Basic Workflow
Execution&lt;/font&gt;&lt;/em&gt;
&lt;/h2&gt;
&lt;p class=BodyTextFirst style="MARGIN: 6pt 0in"&gt;
&lt;font face="Times New Roman" color=#000000 size=3&gt;Executing a workflow is a little
tricky, because workflows default to running on a background thread. That means you
must take steps to ensure that the workflow completes before the host process terminates.&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoBodyText style="MARGIN: 0in 0in 6pt"&gt;
&lt;font face="Times New Roman" color=#000000 size=3&gt;One way to solve this issue is to
always execute a workflow synchronously. Another is to use a thread synchronization
object to prevent the process from terminating until the workflow completes.&lt;/font&gt;
&lt;/p&gt;
&lt;div style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 4pt; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 4pt; PADDING-BOTTOM: 1pt; MARGIN-LEFT: 0.5in; BORDER-LEFT: windowtext 1pt solid; MARGIN-RIGHT: 0.5in; PADDING-TOP: 1pt; BORDER-BOTTOM: windowtext 1pt solid; mso-element: para-border-div; mso-border-shadow: yes"&gt;
&lt;p class=Note style="MARGIN: 12pt 0in"&gt;
&lt;font size=3&gt;&lt;font color=#000000&gt;&lt;font face="Times New Roman"&gt;&lt;b style="mso-bidi-font-weight: normal"&gt;Note: &lt;/b&gt;It
is also possible to suspend and resume workflows, and even to unload them from memory
so they store their state in a database. Later you can reload that workflow instance
and resume it. These advanced scenarios are outside the scope of this book&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;/div&gt;
&lt;h3 style="MARGIN: 12pt 0in 3pt"&gt;&lt;font face=Arial color=#000000&gt;Synchronous Execution&lt;/font&gt;
&lt;/h3&gt;
&lt;p class=BodyTextFirst style="MARGIN: 6pt 0in"&gt;
&lt;font face="Times New Roman" color=#000000 size=3&gt;The code to synchronously execute
a workflow follows a standard pattern:&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoBodyText style="MARGIN: 0in 0in 6pt 0.45in; TEXT-INDENT: -0.25in; mso-list: l0 level1 lfo1"&gt;
&lt;font face="Times New Roman"&gt;&lt;span style="mso-list: Ignore"&gt;&lt;font color=#000000&gt;&lt;font size=3&gt;1.&lt;/font&gt;&lt;span style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/font&gt;&lt;/span&gt;&lt;font color=#000000 size=3&gt;Create
an instance of the &lt;/font&gt;&lt;/font&gt;&lt;span class=CodeInline&gt;&lt;span style="FONT-SIZE: 9pt; mso-bidi-font-size: 10.0pt; mso-bidi-font-family: 'Times New Roman'"&gt;&lt;font face="Courier New" color=#008000&gt;WorkflowRuntime&lt;/font&gt;&lt;/span&gt;&lt;/span&gt;&lt;font face="Times New Roman" color=#000000 size=3&gt;.&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoBodyText style="MARGIN: 0in 0in 6pt 0.45in; TEXT-INDENT: -0.25in; mso-list: l0 level1 lfo1"&gt;
&lt;font face="Times New Roman"&gt;&lt;span style="mso-list: Ignore"&gt;&lt;font color=#000000&gt;&lt;font size=3&gt;2.&lt;/font&gt;&lt;span style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/font&gt;&lt;/span&gt;&lt;font color=#000000 size=3&gt;Create
a synchronization object.&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoBodyText style="MARGIN: 0in 0in 6pt 0.45in; TEXT-INDENT: -0.25in; mso-list: l0 level1 lfo1"&gt;
&lt;font face="Times New Roman"&gt;&lt;span style="mso-list: Ignore"&gt;&lt;font color=#000000&gt;&lt;font size=3&gt;3.&lt;/font&gt;&lt;span style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/font&gt;&lt;/span&gt;&lt;font color=#000000 size=3&gt;Set
up event handlers.&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoBodyText style="MARGIN: 0in 0in 6pt 0.45in; TEXT-INDENT: -0.25in; mso-list: l0 level1 lfo1"&gt;
&lt;font face="Times New Roman"&gt;&lt;span style="mso-list: Ignore"&gt;&lt;font color=#000000&gt;&lt;font size=3&gt;4.&lt;/font&gt;&lt;span style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/font&gt;&lt;/span&gt;&lt;font color=#000000 size=3&gt;Create
workflow instance.&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoBodyText style="MARGIN: 0in 0in 6pt 0.45in; TEXT-INDENT: -0.25in; mso-list: l0 level1 lfo1"&gt;
&lt;font face="Times New Roman"&gt;&lt;span style="mso-list: Ignore"&gt;&lt;font color=#000000&gt;&lt;font size=3&gt;5.&lt;/font&gt;&lt;span style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/font&gt;&lt;/span&gt;&lt;font color=#000000 size=3&gt;Ensure
you have a valid principal object.&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoBodyText style="MARGIN: 0in 0in 6pt 0.45in; TEXT-INDENT: -0.25in; mso-list: l0 level1 lfo1"&gt;
&lt;font face="Times New Roman"&gt;&lt;span style="mso-list: Ignore"&gt;&lt;font color=#000000&gt;&lt;font size=3&gt;6.&lt;/font&gt;&lt;span style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/font&gt;&lt;/span&gt;&lt;font color=#000000 size=3&gt;Start
the workflow.&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoBodyText style="MARGIN: 0in 0in 6pt 0.45in; TEXT-INDENT: -0.25in; mso-list: l0 level1 lfo1"&gt;
&lt;font face="Times New Roman"&gt;&lt;span style="mso-list: Ignore"&gt;&lt;font color=#000000&gt;&lt;font size=3&gt;7.&lt;/font&gt;&lt;span style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/font&gt;&lt;/span&gt;&lt;font color=#000000 size=3&gt;Wait
for the workflow to complete.&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoBodyText style="MARGIN: 0in 0in 6pt"&gt;
&lt;font face="Times New Roman" color=#000000 size=3&gt;The only step unique to CSLA .NET
is number 5, and that is only required if you are using custom authentication. The
WF runtime will automatically ensure that the background thread that executes the
workflow has the same principal as the thread that calls the workflow’s &lt;/font&gt;&lt;span class=CodeInline&gt;&lt;span style="FONT-SIZE: 9pt; mso-bidi-font-size: 10.0pt; mso-bidi-font-family: 'Times New Roman'"&gt;&lt;font face="Courier New" color=#008000&gt;Start()&lt;/font&gt;&lt;/span&gt;&lt;/span&gt;&lt;font face="Times New Roman" color=#000000 size=3&gt; method,
but you must ensure that the principal is set on the current thread before calling &lt;/font&gt;&lt;span class=CodeInline&gt;&lt;span style="FONT-SIZE: 9pt; mso-bidi-font-size: 10.0pt; mso-bidi-font-family: 'Times New Roman'"&gt;&lt;font face="Courier New" color=#008000&gt;Start()&lt;/font&gt;&lt;/span&gt;&lt;/span&gt;&lt;font face="Times New Roman" color=#000000 size=3&gt;.&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoBodyText style="MARGIN: 0in 0in 6pt"&gt;
&lt;font face="Times New Roman" color=#000000 size=3&gt;The following code implements these
steps to execute the &lt;/font&gt;&lt;span class=CodeInline&gt;&lt;span style="FONT-SIZE: 9pt; mso-bidi-font-size: 10.0pt; mso-bidi-font-family: 'Times New Roman'"&gt;&lt;font face="Courier New" color=#008000&gt;ProjectWorkflow&lt;/font&gt;&lt;/span&gt;&lt;/span&gt;&lt;font face="Times New Roman" color=#000000 size=3&gt; implemented
earlier in this chapter:&lt;/font&gt;
&lt;/p&gt;
&lt;div style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN-LEFT: 0.1in; BORDER-LEFT: medium none; MARGIN-RIGHT: 0in; PADDING-TOP: 1pt; BORDER-BOTTOM: medium none; mso-element: para-border-div; mso-border-top-alt: solid windowtext .5pt"&gt;
&lt;p class=CodeFirst style="MARGIN: 12pt 0in 0pt"&gt;
&lt;font color=#000000&gt;&lt;font face="Courier New"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;using
(WorkflowRuntime workflowRuntime = new WorkflowRuntime())&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;/div&gt;
&lt;p class=Code style="MARGIN: 0in 0in 0pt 0.1in"&gt;
&lt;font color=#000000&gt;&lt;font face="Courier New"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=Code style="MARGIN: 0in 0in 0pt 0.1in"&gt;
&lt;font color=#000000&gt;&lt;font face="Courier New"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;Exeception
error = null;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=Code style="MARGIN: 0in 0in 0pt 0.1in"&gt;&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;
&lt;o:p&gt;
&lt;font face="Courier New" color=#000000&gt;&amp;nbsp;&lt;/font&gt;
&lt;/o:p&gt;
&lt;/p&gt;
&lt;p class=Code style="MARGIN: 0in 0in 0pt 0.1in"&gt;
&lt;font color=#000000&gt;&lt;font face="Courier New"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;AutoResetEvent
waitHandle = new AutoResetEvent(false);&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=Code style="MARGIN: 0in 0in 0pt 0.1in"&gt;
&lt;font color=#000000&gt;&lt;font face="Courier New"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;workflowRuntime.WorkflowCompleted
+= &lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=Code style="MARGIN: 0in 0in 0pt 0.1in"&gt;
&lt;font color=#000000&gt;&lt;font face="Courier New"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;delegate(object
sender, WorkflowCompletedEventArgs e) &lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=Code style="MARGIN: 0in 0in 0pt 0.1in"&gt;
&lt;font color=#000000&gt;&lt;font face="Courier New"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=Code style="MARGIN: 0in 0in 0pt 0.1in"&gt;
&lt;font color=#000000&gt;&lt;font face="Courier New"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;waitHandle.Set(); &lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=Code style="MARGIN: 0in 0in 0pt 0.1in"&gt;
&lt;font color=#000000&gt;&lt;font face="Courier New"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;};&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=Code style="MARGIN: 0in 0in 0pt 0.1in"&gt;
&lt;font color=#000000&gt;&lt;font face="Courier New"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;workflowRuntime.WorkflowTerminated
+= &lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=Code style="MARGIN: 0in 0in 0pt 0.1in"&gt;
&lt;font color=#000000&gt;&lt;font face="Courier New"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;delegate(object
sender, WorkflowTerminatedEventArgs e)&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=Code style="MARGIN: 0in 0in 0pt 0.1in"&gt;
&lt;font color=#000000&gt;&lt;font face="Courier New"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=Code style="MARGIN: 0in 0in 0pt 0.1in"&gt;
&lt;font color=#000000&gt;&lt;font face="Courier New"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;error
= e.Exception;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=Code style="MARGIN: 0in 0in 0pt 0.1in"&gt;
&lt;font color=#000000&gt;&lt;font face="Courier New"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;waitHandle.Set();&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=Code style="MARGIN: 0in 0in 0pt 0.1in"&gt;
&lt;font color=#000000&gt;&lt;font face="Courier New"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;};&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=Code style="MARGIN: 0in 0in 0pt 0.1in"&gt;
&lt;o:p&gt;
&lt;font face="Courier New" color=#000000&gt;&amp;nbsp;&lt;/font&gt;
&lt;/o:p&gt;
&lt;/p&gt;
&lt;p class=Code style="MARGIN: 0in 0in 0pt 0.1in"&gt;
&lt;font color=#000000&gt;&lt;font face="Courier New"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;//
create workflow instance&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=Code style="MARGIN: 0in 0in 0pt 0.1in"&gt;
&lt;font color=#000000&gt;&lt;font face="Courier New"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;Dictionary&amp;lt;string,object&amp;gt;
parameters = new Dictionary&amp;lt;string,object&amp;gt;();&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=Code style="MARGIN: 0in 0in 0pt 0.1in"&gt;
&lt;font color=#000000&gt;&lt;font face="Courier New"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;parameters.Add("ProjectId",
projectId);&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=Code style="MARGIN: 0in 0in 0pt 0.1in"&gt;
&lt;font color=#000000&gt;&lt;font face="Courier New"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;WorkflowInstance
instance = &lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=Code style="MARGIN: 0in 0in 0pt 0.1in"&gt;
&lt;font color=#000000&gt;&lt;font face="Courier New"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;workflowRuntime.CreateWorkflow(&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=Code style="MARGIN: 0in 0in 0pt 0.1in"&gt;
&lt;font color=#000000&gt;&lt;font face="Courier New"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;typeof(PTWorkflow.ProjectWorkflow), &lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=Code style="MARGIN: 0in 0in 0pt 0.1in"&gt;
&lt;font color=#000000&gt;&lt;font face="Courier New"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;parameters);&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=Code style="MARGIN: 0in 0in 0pt 0.1in"&gt;
&lt;o:p&gt;
&lt;font face="Courier New" color=#000000&gt;&amp;nbsp;&lt;/font&gt;
&lt;/o:p&gt;
&lt;/p&gt;
&lt;p class=Code style="MARGIN: 0in 0in 0pt 0.1in"&gt;
&lt;font color=#000000&gt;&lt;font face="Courier New"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;//
login before starting WF instance&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=Code style="MARGIN: 0in 0in 0pt 0.1in"&gt;
&lt;font color=#000000&gt;&lt;font face="Courier New"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;ProjectTracker.Library.Security.PTPrincipal.Login("pm",
"pm");&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=Code style="MARGIN: 0in 0in 0pt 0.1in"&gt;
&lt;o:p&gt;
&lt;font face="Courier New" color=#000000&gt;&amp;nbsp;&lt;/font&gt;
&lt;/o:p&gt;
&lt;/p&gt;
&lt;p class=Code style="MARGIN: 0in 0in 0pt 0.1in"&gt;
&lt;font color=#000000&gt;&lt;font face="Courier New"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;//
execute workflow&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=Code style="MARGIN: 0in 0in 0pt 0.1in"&gt;
&lt;font color=#000000&gt;&lt;font face="Courier New"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;instance.Start();&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=Code style="MARGIN: 0in 0in 0pt 0.1in"&gt;
&lt;o:p&gt;
&lt;font face="Courier New" color=#000000&gt;&amp;nbsp;&lt;/font&gt;
&lt;/o:p&gt;
&lt;/p&gt;
&lt;p class=Code style="MARGIN: 0in 0in 0pt 0.1in"&gt;
&lt;font color=#000000&gt;&lt;font face="Courier New"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;//
wait for workflow to complete&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=Code style="MARGIN: 0in 0in 0pt 0.1in"&gt;
&lt;font color=#000000&gt;&lt;font face="Courier New"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;waitHandle.WaitOne();&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=Code style="MARGIN: 0in 0in 0pt 0.1in"&gt;
&lt;o:p&gt;
&lt;font face="Courier New" color=#000000&gt;&amp;nbsp;&lt;/font&gt;
&lt;/o:p&gt;
&lt;/p&gt;
&lt;p class=Code style="MARGIN: 0in 0in 0pt 0.1in"&gt;
&lt;font color=#000000&gt;&lt;font face="Courier New"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/span&gt;//
throw any workflow exception&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=Code style="MARGIN: 0in 0in 0pt 0.1in"&gt;
&lt;font color=#000000&gt;&lt;font face="Courier New"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;if
(error != null)&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=Code style="MARGIN: 0in 0in 0pt 0.1in"&gt;
&lt;font color=#000000&gt;&lt;font face="Courier New"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;throw
error;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;div style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 1pt; MARGIN-LEFT: 0.1in; BORDER-LEFT: medium none; MARGIN-RIGHT: 0in; PADDING-TOP: 0in; BORDER-BOTTOM: windowtext 1pt solid; mso-element: para-border-div; mso-border-bottom-alt: solid windowtext .5pt"&gt;
&lt;p class=CodeLast style="MARGIN: 0in 0in 12pt"&gt;
&lt;font color=#000000&gt;&lt;font face="Courier New"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;/div&gt;
&lt;p class=MsoBodyText style="MARGIN: 0in 0in 6pt"&gt;
&lt;font face="Times New Roman" color=#000000 size=3&gt;Creating the workflow instance involves
setting up a &lt;/font&gt;&lt;span class=CodeInline&gt;&lt;span style="FONT-SIZE: 9pt; mso-bidi-font-size: 10.0pt; mso-bidi-font-family: 'Times New Roman'"&gt;&lt;font face="Courier New" color=#008000&gt;Dictionary&amp;lt;string,
object&amp;gt;&lt;/font&gt;&lt;/span&gt;&lt;/span&gt;&lt;font face="Times New Roman" color=#000000 size=3&gt; that
contains name/value pairs for any parameters to be passed into th workflow instance:&lt;/font&gt;
&lt;/p&gt;
&lt;div style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN-LEFT: 0.1in; BORDER-LEFT: medium none; MARGIN-RIGHT: 0in; PADDING-TOP: 1pt; BORDER-BOTTOM: medium none; mso-element: para-border-div; mso-border-top-alt: solid windowtext .5pt"&gt;
&lt;p class=CodeFirst style="MARGIN: 12pt 0in 0pt"&gt;
&lt;font color=#000000&gt;&lt;font face="Courier New"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;//
create workflow instance&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;/div&gt;
&lt;p class=Code style="MARGIN: 0in 0in 0pt 0.1in"&gt;
&lt;font color=#000000&gt;&lt;font face="Courier New"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;Dictionary&amp;lt;string,object&amp;gt;
parameters = new Dictionary&amp;lt;string,object&amp;gt;();&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=Code style="MARGIN: 0in 0in 0pt 0.1in"&gt;
&lt;font color=#000000&gt;&lt;font face="Courier New"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;parameters.Add("ProjectId",
projectId);&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=Code style="MARGIN: 0in 0in 0pt 0.1in"&gt;
&lt;font color=#000000&gt;&lt;font face="Courier New"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;WorkflowInstance
instance = &lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=Code style="MARGIN: 0in 0in 0pt 0.1in"&gt;
&lt;font color=#000000&gt;&lt;font face="Courier New"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;workflowRuntime.CreateWorkflow(&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=Code style="MARGIN: 0in 0in 0pt 0.1in"&gt;
&lt;font color=#000000&gt;&lt;font face="Courier New"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;typeof(PTWorkflow.ProjectWorkflow), &lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;div style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 1pt; MARGIN-LEFT: 0.1in; BORDER-LEFT: medium none; MARGIN-RIGHT: 0in; PADDING-TOP: 0in; BORDER-BOTTOM: windowtext 1pt solid; mso-element: para-border-div; mso-border-bottom-alt: solid windowtext .5pt"&gt;
&lt;p class=CodeLast style="MARGIN: 0in 0in 12pt"&gt;
&lt;font color=#000000&gt;&lt;font face="Courier New"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;parameters);&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;/div&gt;
&lt;p class=MsoBodyText style="MARGIN: 0in 0in 6pt"&gt;
&lt;font face="Times New Roman" color=#000000 size=3&gt;The name in the dictionary must
correspond to the name of a dependency property defined by the workflow, and of course
the type of the value must match the dependency property type.&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoBodyText style="MARGIN: 0in 0in 6pt"&gt;
&lt;font face="Times New Roman" color=#000000 size=3&gt;Keep in mind that creating an instance
of a workflow does not &lt;i style="mso-bidi-font-style: normal"&gt;start&lt;/i&gt; the workflow.
The workflow won’t start executing until the &lt;/font&gt;&lt;span class=CodeInline&gt;&lt;span style="FONT-SIZE: 9pt; mso-bidi-font-size: 10.0pt; mso-bidi-font-family: 'Times New Roman'"&gt;&lt;font face="Courier New" color=#008000&gt;Start()&lt;/font&gt;&lt;/span&gt;&lt;/span&gt;&lt;font face="Times New Roman" color=#000000 size=3&gt; method
is called later in the code.&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoBodyText style="MARGIN: 0in 0in 6pt"&gt;
&lt;font face="Times New Roman" color=#000000 size=3&gt;The &lt;/font&gt;&lt;span class=CodeInline&gt;&lt;span style="FONT-SIZE: 9pt; mso-bidi-font-size: 10.0pt; mso-bidi-font-family: 'Times New Roman'"&gt;&lt;font face="Courier New" color=#008000&gt;waitHandle&lt;/font&gt;&lt;/span&gt;&lt;/span&gt;&lt;font face="Times New Roman" color=#000000 size=3&gt; synchronization
object is the key to making this process synchronous. The &lt;/font&gt;&lt;span class=CodeInline&gt;&lt;span style="FONT-SIZE: 9pt; mso-bidi-font-size: 10.0pt; mso-bidi-font-family: 'Times New Roman'"&gt;&lt;font face="Courier New" color=#008000&gt;waitHandle&lt;/font&gt;&lt;/span&gt;&lt;/span&gt;&lt;font face="Times New Roman" color=#000000 size=3&gt; object
starts out unset because &lt;/font&gt;&lt;span class=CodeInline&gt;&lt;span style="FONT-SIZE: 9pt; mso-bidi-font-size: 10.0pt; mso-bidi-font-family: 'Times New Roman'"&gt;&lt;font face="Courier New" color=#008000&gt;false&lt;/font&gt;&lt;/span&gt;&lt;/span&gt;&lt;font face="Times New Roman" color=#000000 size=3&gt; is
passed to its constructor as its initial state:&lt;/font&gt;
&lt;/p&gt;
&lt;div style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 0in; PADDING-BOTTOM: 1pt; MARGIN-LEFT: 0.1in; BORDER-LEFT: medium none; MARGIN-RIGHT: 0in; PADDING-TOP: 1pt; BORDER-BOTTOM: windowtext 1pt solid; mso-element: para-border-div; mso-border-top-alt: solid windowtext .5pt; mso-border-bottom-alt: solid windowtext .5pt"&gt;
&lt;p class=CodeSingle style="MARGIN: 12pt 0in"&gt;
&lt;font color=#000000&gt;&lt;font face="Courier New"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;AutoResetEvent
waitHandle = new AutoResetEvent(false);&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;/div&gt;
&lt;p class=MsoBodyText style="MARGIN: 0in 0in 6pt"&gt;
&lt;font face="Times New Roman" color=#000000 size=3&gt;At the bottom of the code is a line
that calls &lt;/font&gt;&lt;span class=CodeInline&gt;&lt;span style="FONT-SIZE: 9pt; mso-bidi-font-size: 10.0pt; mso-bidi-font-family: 'Times New Roman'"&gt;&lt;font face="Courier New" color=#008000&gt;WaitOne()&lt;/font&gt;&lt;/span&gt;&lt;/span&gt;&lt;font face="Times New Roman" color=#000000 size=3&gt;,
thus blocking the current thread until &lt;/font&gt;&lt;span class=CodeInline&gt;&lt;span style="FONT-SIZE: 9pt; mso-bidi-font-size: 10.0pt; mso-bidi-font-family: 'Times New Roman'"&gt;&lt;font face="Courier New" color=#008000&gt;waitHandle&lt;/font&gt;&lt;/span&gt;&lt;/span&gt;&lt;font face="Times New Roman" color=#000000 size=3&gt; is
set:&lt;/font&gt;
&lt;/p&gt;
&lt;div style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN-LEFT: 0.1in; BORDER-LEFT: medium none; MARGIN-RIGHT: 0in; PADDING-TOP: 1pt; BORDER-BOTTOM: medium none; mso-element: para-border-div; mso-border-top-alt: solid windowtext .5pt"&gt;
&lt;p class=CodeFirst style="MARGIN: 12pt 0in 0pt"&gt;
&lt;font color=#000000&gt;&lt;font face="Courier New"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;//
execute workflow&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;/div&gt;
&lt;p class=Code style="MARGIN: 0in 0in 0pt 0.1in"&gt;
&lt;font color=#000000&gt;&lt;font face="Courier New"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;instance.Start();&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=Code style="MARGIN: 0in 0in 0pt 0.1in"&gt;
&lt;o:p&gt;
&lt;font face="Courier New" color=#000000&gt;&amp;nbsp;&lt;/font&gt;
&lt;/o:p&gt;
&lt;/p&gt;
&lt;p class=CodeBold style="MARGIN: 0in 0in 0pt 0.1in"&gt;
&lt;font color=#000000&gt;&lt;font style="BACKGROUND-COLOR: #d9d9d9"&gt;&lt;strong&gt;&lt;font face="Courier New"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;//
wait for workflow to complete&lt;/font&gt;&lt;/strong&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;div style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; BACKGROUND: #d9d9d9; PADDING-BOTTOM: 1pt; MARGIN-LEFT: 0.1in; BORDER-LEFT: medium none; MARGIN-RIGHT: 0in; PADDING-TOP: 0in; BORDER-BOTTOM: windowtext 1pt solid; mso-element: para-border-div; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-border-bottom-alt: solid windowtext .5pt"&gt;
&lt;p class=CodeBoldLast style="BACKGROUND: #d9d9d9; MARGIN: 0in 0in 12pt; mso-background-themecolor: background1; mso-background-themeshade: 217"&gt;
&lt;strong&gt;&lt;font color=#000000&gt;&lt;font face="Courier New"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;waitHandle.WaitOne();&lt;/font&gt;&lt;/font&gt;&lt;/strong&gt;
&lt;/p&gt;
&lt;/div&gt;
&lt;p class=MsoBodyText style="MARGIN: 0in 0in 6pt"&gt;
&lt;font face="Times New Roman" color=#000000 size=3&gt;While the current (starting) thread
is blocked, the workflow is busy executing on a background thread. In other words,
the &lt;/font&gt;&lt;span class=CodeInline&gt;&lt;span style="FONT-SIZE: 9pt; mso-bidi-font-size: 10.0pt; mso-bidi-font-family: 'Times New Roman'"&gt;&lt;font face="Courier New" color=#008000&gt;Start()&lt;/font&gt;&lt;/span&gt;&lt;/span&gt;&lt;font face="Times New Roman" color=#000000 size=3&gt; call
returns immediately, having just started the workflow instance executing on a background
thread. Without the &lt;/font&gt;&lt;span class=CodeInline&gt;&lt;span style="FONT-SIZE: 9pt; mso-bidi-font-size: 10.0pt; mso-bidi-font-family: 'Times New Roman'"&gt;&lt;font face="Courier New" color=#008000&gt;WaitOne()&lt;/font&gt;&lt;/span&gt;&lt;/span&gt;&lt;font face="Times New Roman" color=#000000 size=3&gt; call,
the current thread would exit the code block, which would dispose the WF engine instance
while it is executing the workflow. The result would be an exception.&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoBodyText style="MARGIN: 0in 0in 6pt"&gt;
&lt;font face="Times New Roman" color=#000000 size=3&gt;Notice how the event handlers for
the &lt;/font&gt;&lt;span class=CodeInline&gt;&lt;span style="FONT-SIZE: 9pt; mso-bidi-font-size: 10.0pt; mso-bidi-font-family: 'Times New Roman'"&gt;&lt;font face="Courier New" color=#008000&gt;WorkflowCompleted&lt;/font&gt;&lt;/span&gt;&lt;/span&gt;&lt;font face="Times New Roman" color=#000000 size=3&gt; and &lt;/font&gt;&lt;span class=CodeInline&gt;&lt;span style="FONT-SIZE: 9pt; mso-bidi-font-size: 10.0pt; mso-bidi-font-family: 'Times New Roman'"&gt;&lt;font face="Courier New" color=#008000&gt;WorkflowTerminated&lt;/font&gt;&lt;/span&gt;&lt;/span&gt;&lt;font face="Times New Roman" color=#000000 size=3&gt; events
both call &lt;/font&gt;&lt;span class=CodeInline&gt;&lt;span style="FONT-SIZE: 9pt; mso-bidi-font-size: 10.0pt; mso-bidi-font-family: 'Times New Roman'"&gt;&lt;font face="Courier New" color=#008000&gt;waitHandle.Set()&lt;/font&gt;&lt;/span&gt;&lt;/span&gt;&lt;font face="Times New Roman" color=#000000 size=3&gt;.
These events are raised by the WF engine when the workflow either completes or terminates
unexpectedly. Either way, by calling the &lt;/font&gt;&lt;span class=CodeInline&gt;&lt;span style="FONT-SIZE: 9pt; mso-bidi-font-size: 10.0pt; mso-bidi-font-family: 'Times New Roman'"&gt;&lt;font face="Courier New" color=#008000&gt;Set()&lt;/font&gt;&lt;/span&gt;&lt;/span&gt;&lt;font face="Times New Roman" color=#000000 size=3&gt; method,
the current thread is released so it can continue running.&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoBodyText style="MARGIN: 0in 0in 6pt"&gt;
&lt;font face="Times New Roman" color=#000000 size=3&gt;In the case of a workflow terminating
unexpectedly, the exception from the workflow is made available to the &lt;/font&gt;&lt;span class=CodeInline&gt;&lt;span style="FONT-SIZE: 9pt; mso-bidi-font-size: 10.0pt; mso-bidi-font-family: 'Times New Roman'"&gt;&lt;font face="Courier New" color=#008000&gt;WorkflowTerminated&lt;/font&gt;&lt;/span&gt;&lt;/span&gt;&lt;font face="Times New Roman" color=#000000 size=3&gt; event
handler. You can choose what to do with this information as appropriate for your application.
One technique is shown here, which is to store the &lt;/font&gt;&lt;span class=CodeInline&gt;&lt;span style="FONT-SIZE: 9pt; mso-bidi-font-size: 10.0pt; mso-bidi-font-family: 'Times New Roman'"&gt;&lt;font face="Courier New" color=#008000&gt;Exception&lt;/font&gt;&lt;/span&gt;&lt;/span&gt;&lt;font face="Times New Roman" color=#000000 size=3&gt; object
in a field:&lt;/font&gt;
&lt;/p&gt;
&lt;div style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN-LEFT: 0.1in; BORDER-LEFT: medium none; MARGIN-RIGHT: 0in; PADDING-TOP: 1pt; BORDER-BOTTOM: medium none; mso-element: para-border-div; mso-border-top-alt: solid windowtext .5pt"&gt;
&lt;p class=CodeFirst style="MARGIN: 12pt 0in 0pt"&gt;
&lt;font color=#000000&gt;&lt;font face="Courier New"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;delegate(object
sender, WorkflowTerminatedEventArgs e)&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;/div&gt;
&lt;p class=Code style="MARGIN: 0in 0in 0pt 0.1in"&gt;
&lt;font color=#000000&gt;&lt;font face="Courier New"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=CodeBold style="MARGIN: 0in 0in 0pt 0.1in"&gt;
&lt;strong&gt;&lt;font color=#000000&gt;&lt;font style="BACKGROUND-COLOR: #d9d9d9"&gt;&lt;font face="Courier New"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;error
= e.Exception;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/strong&gt;
&lt;/p&gt;
&lt;p class=Code style="MARGIN: 0in 0in 0pt 0.1in"&gt;
&lt;font color=#000000&gt;&lt;font face="Courier New"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;waitHandle.Set();&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;div style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 1pt; MARGIN-LEFT: 0.1in; BORDER-LEFT: medium none; MARGIN-RIGHT: 0in; PADDING-TOP: 0in; BORDER-BOTTOM: windowtext 1pt solid; mso-element: para-border-div; mso-border-bottom-alt: solid windowtext .5pt"&gt;
&lt;p class=CodeLast style="MARGIN: 0in 0in 12pt"&gt;
&lt;font color=#000000&gt;&lt;font face="Courier New"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;};&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;/div&gt;
&lt;p class=MsoBodyText style="MARGIN: 0in 0in 6pt"&gt;
&lt;font face="Times New Roman" color=#000000 size=3&gt;And then have the current thread
throw the exception once it is unblocked:&lt;/font&gt;
&lt;/p&gt;
&lt;div style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN-LEFT: 0.1in; BORDER-LEFT: medium none; MARGIN-RIGHT: 0in; PADDING-TOP: 1pt; BORDER-BOTTOM: medium none; mso-element: para-border-div; mso-border-top-alt: solid windowtext .5pt"&gt;
&lt;p class=CodeFirst style="MARGIN: 12pt 0in 0pt"&gt;
&lt;font color=#000000&gt;&lt;font face="Courier New"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;//
wait for workflow to complete&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;/div&gt;
&lt;p class=Code style="MARGIN: 0in 0in 0pt 0.1in"&gt;
&lt;font color=#000000&gt;&lt;font face="Courier New"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;waitHandle.WaitOne();&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=Code style="MARGIN: 0in 0in 0pt 0.1in"&gt;
&lt;o:p&gt;
&lt;font face="Courier New" color=#000000&gt;&amp;nbsp;&lt;/font&gt;
&lt;/o:p&gt;
&lt;/p&gt;
&lt;p class=CodeBold style="MARGIN: 0in 0in 0pt 0.1in"&gt;
&lt;font color=#000000&gt;&lt;font style="BACKGROUND-COLOR: #d9d9d9"&gt;&lt;strong&gt;&lt;font face="Courier New"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;//
throw any workflow exception&lt;/font&gt;&lt;/strong&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=CodeBold style="MARGIN: 0in 0in 0pt 0.1in"&gt;
&lt;font color=#000000&gt;&lt;font style="BACKGROUND-COLOR: #d9d9d9"&gt;&lt;strong&gt;&lt;font face="Courier New"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;if
(error != null)&lt;/font&gt;&lt;/strong&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;div style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; BACKGROUND: #d9d9d9; PADDING-BOTTOM: 1pt; MARGIN-LEFT: 0.1in; BORDER-LEFT: medium none; MARGIN-RIGHT: 0in; PADDING-TOP: 0in; BORDER-BOTTOM: windowtext 1pt solid; mso-element: para-border-div; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-border-bottom-alt: solid windowtext .5pt"&gt;
&lt;p class=CodeBoldLast style="BACKGROUND: #d9d9d9; MARGIN: 0in 0in 12pt; mso-background-themecolor: background1; mso-background-themeshade: 217"&gt;
&lt;strong&gt;&lt;font color=#000000&gt;&lt;font face="Courier New"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;throw
error;&lt;/font&gt;&lt;/font&gt;&lt;/strong&gt;
&lt;/p&gt;
&lt;/div&gt;
&lt;p class=MsoBodyText style="MARGIN: 0in 0in 6pt"&gt;
&lt;font face="Times New Roman" color=#000000 size=3&gt;The result of this code is that
the workflow appears to run synchronously, even though it really executes on a background
thread.&lt;/font&gt;
&lt;/p&gt;
&lt;h3 style="MARGIN: 12pt 0in 3pt"&gt;&lt;font face=Arial color=#000000&gt;Asynchronous Execution&lt;/font&gt;
&lt;/h3&gt;
&lt;p class=BodyTextFirst style="MARGIN: 6pt 0in"&gt;
&lt;font face="Times New Roman" color=#000000 size=3&gt;Allowing a workflow to run asynchronously
is just a slightly more complex version of running the workflow synchronously. The
important thing is to ensure that your process doesn’t exit until the workflow is
complete. This means that the synchronization object must be available at a broader
scope so you can write code to prevent the application from closing if the workflow
is still running.&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoBodyText style="MARGIN: 0in 0in 6pt"&gt;
&lt;font face="Times New Roman" color=#000000 size=3&gt;You also must come up with a way
to deal with any exception object in the case that the workflow terminates unexpectedly.
One solution is to elevate the &lt;/font&gt;&lt;span class=CodeInline&gt;&lt;span style="FONT-SIZE: 9pt; mso-bidi-font-size: 10.0pt; mso-bidi-font-family: 'Times New Roman'"&gt;&lt;font face="Courier New" color=#008000&gt;error&lt;/font&gt;&lt;/span&gt;&lt;/span&gt;&lt;font face="Times New Roman" color=#000000 size=3&gt; field
from the previous example to a broader scope as well.&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoBodyText style="MARGIN: 0in 0in 6pt"&gt;
&lt;font face="Times New Roman" color=#000000 size=3&gt;Finally, the &lt;/font&gt;&lt;span class=CodeInline&gt;&lt;span style="FONT-SIZE: 9pt; mso-bidi-font-size: 10.0pt; mso-bidi-font-family: 'Times New Roman'"&gt;&lt;font face="Courier New" color=#008000&gt;WorkflowRuntime&lt;/font&gt;&lt;/span&gt;&lt;/span&gt;&lt;font face="Times New Roman" color=#000000 size=3&gt; instance
must remain in memory until the workflow completes.&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoBodyText style="MARGIN: 0in 0in 6pt"&gt;
&lt;font face="Times New Roman" color=#000000 size=3&gt;This means that you must define
these fields so they exist at an application level, for instance using &lt;/font&gt;&lt;span class=CodeInline&gt;&lt;span style="FONT-SIZE: 9pt; mso-bidi-font-size: 10.0pt; mso-bidi-font-family: 'Times New Roman'"&gt;&lt;font face="Courier New" color=#008000&gt;static&lt;/font&gt;&lt;/span&gt;&lt;/span&gt;&lt;font face="Times New Roman" color=#000000 size=3&gt; fields:&lt;/font&gt;
&lt;/p&gt;
&lt;div style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN-LEFT: 0.1in; BORDER-LEFT: medium none; MARGIN-RIGHT: 0in; PADDING-TOP: 1pt; BORDER-BOTTOM: medium none; mso-element: para-border-div; mso-border-top-alt: solid windowtext .5pt"&gt;
&lt;p class=CodeFirst style="MARGIN: 12pt 0in 0pt"&gt;
&lt;font color=#000000&gt;&lt;font face="Courier New"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;private
static AutoResetEvent _waitHandle = null;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;/div&gt;
&lt;p class=Code style="MARGIN: 0in 0in 0pt 0.1in"&gt;
&lt;font color=#000000&gt;&lt;font face="Courier New"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;private
static Exception _workflowError = null;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;div style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 1pt; MARGIN-LEFT: 0.1in; BORDER-LEFT: medium none; MARGIN-RIGHT: 0in; PADDING-TOP: 0in; BORDER-BOTTOM: windowtext 1pt solid; mso-element: para-border-div; mso-border-bottom-alt: solid windowtext .5pt"&gt;
&lt;p class=CodeLast style="MARGIN: 0in 0in 12pt"&gt;
&lt;font color=#000000&gt;&lt;font face="Courier New"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;private
static WorkflowRuntime _workflowRuntime = null;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;/div&gt;
&lt;p class=MsoBodyText style="MARGIN: 0in 0in 6pt"&gt;
&lt;font face="Times New Roman" color=#000000 size=3&gt;Then you can create a method to
start the workflow:&lt;/font&gt;
&lt;/p&gt;
&lt;div style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN-LEFT: 0.1in; BORDER-LEFT: medium none; MARGIN-RIGHT: 0in; PADDING-TOP: 1pt; BORDER-BOTTOM: medium none; mso-element: para-border-div; mso-border-top-alt: solid windowtext .5pt"&gt;
&lt;p class=CodeFirst style="MARGIN: 12pt 0in 0pt"&gt;
&lt;font color=#000000&gt;&lt;font face="Courier New"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;public
static void BeginWorkflow(Guid projectId)&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;/div&gt;
&lt;p class=Code style="MARGIN: 0in 0in 0pt 0.1in"&gt;
&lt;font color=#000000&gt;&lt;font face="Courier New"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=Code style="MARGIN: 0in 0in 0pt 0.1in"&gt;
&lt;font color=#000000&gt;&lt;font face="Courier New"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;_workflowRuntime
= new WorkflowRuntime();&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=Code style="MARGIN: 0in 0in 0pt 0.1in"&gt;
&lt;font color=#000000&gt;&lt;font face="Courier New"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;_waitHandle
= new AutoResetEvent(false);&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=Code style="MARGIN: 0in 0in 0pt 0.1in"&gt;
&lt;font color=#000000&gt;&lt;font face="Courier New"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;_workflowRuntime.WorkflowCompleted
+= &lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=Code style="MARGIN: 0in 0in 0pt 0.1in"&gt;
&lt;font color=#000000&gt;&lt;font face="Courier New"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;delegate(object
sender, WorkflowCompletedEventArgs e) &lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=Code style="MARGIN: 0in 0in 0pt 0.1in"&gt;
&lt;font color=#000000&gt;&lt;font face="Courier New"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=Code style="MARGIN: 0in 0in 0pt 0.1in"&gt;
&lt;font color=#000000&gt;&lt;font face="Courier New"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;_waitHandle.Set(); &lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=Code style="MARGIN: 0in 0in 0pt 0.1in"&gt;
&lt;font color=#000000&gt;&lt;font face="Courier New"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;};&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=Code style="MARGIN: 0in 0in 0pt 0.1in"&gt;
&lt;font color=#000000&gt;&lt;font face="Courier New"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;_workflowRuntime.WorkflowTerminated
+= &lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=Code style="MARGIN: 0in 0in 0pt 0.1in"&gt;
&lt;font color=#000000&gt;&lt;font face="Courier New"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;delegate(object
sender, WorkflowTerminatedEventArgs e)&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=Code style="MARGIN: 0in 0in 0pt 0.1in"&gt;
&lt;font color=#000000&gt;&lt;font face="Courier New"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=Code style="MARGIN: 0in 0in 0pt 0.1in"&gt;
&lt;font color=#000000&gt;&lt;font face="Courier New"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;_workflowError
= e.Exception;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=Code style="MARGIN: 0in 0in 0pt 0.1in"&gt;
&lt;font color=#000000&gt;&lt;font face="Courier New"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;_waitHandle.Set();&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=Code style="MARGIN: 0in 0in 0pt 0.1in"&gt;
&lt;font color=#000000&gt;&lt;font face="Courier New"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;};&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=Code style="MARGIN: 0in 0in 0pt 0.1in"&gt;
&lt;o:p&gt;
&lt;font face="Courier New" color=#000000&gt;&amp;nbsp;&lt;/font&gt;
&lt;/o:p&gt;
&lt;/p&gt;
&lt;p class=Code style="MARGIN: 0in 0in 0pt 0.1in"&gt;
&lt;font color=#000000&gt;&lt;font face="Courier New"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;//
create workflow instance&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=Code style="MARGIN: 0in 0in 0pt 0.1in"&gt;
&lt;font color=#000000&gt;&lt;font face="Courier New"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;Dictionary&amp;lt;string,object&amp;gt;
parameters = new Dictionary&amp;lt;string,object&amp;gt;();&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=Code style="MARGIN: 0in 0in 0pt 0.1in"&gt;
&lt;font color=#000000&gt;&lt;font face="Courier New"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;parameters.Add("ProjectId",
projectId);&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=Code style="MARGIN: 0in 0in 0pt 0.1in"&gt;
&lt;font color=#000000&gt;&lt;font face="Courier New"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;WorkflowInstance
instance = &lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=Code style="MARGIN: 0in 0in 0pt 0.1in"&gt;
&lt;font color=#000000&gt;&lt;font face="Courier New"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;_workflowRuntime.CreateWorkflow(&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=Code style="MARGIN: 0in 0in 0pt 0.1in"&gt;
&lt;font color=#000000&gt;&lt;font face="Courier New"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;typeof(PTWorkflow.ProjectWorkflow), &lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=Code style="MARGIN: 0in 0in 0pt 0.1in"&gt;
&lt;font color=#000000&gt;&lt;font face="Courier New"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;parameters);&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=Code style="MARGIN: 0in 0in 0pt 0.1in"&gt;
&lt;o:p&gt;
&lt;font face="Courier New" color=#000000&gt;&amp;nbsp;&lt;/font&gt;
&lt;/o:p&gt;
&lt;/p&gt;
&lt;p class=Code style="MARGIN: 0in 0in 0pt 0.1in"&gt;
&lt;font color=#000000&gt;&lt;font face="Courier New"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;//
login before starting WF instance&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=Code style="MARGIN: 0in 0in 0pt 0.1in"&gt;
&lt;font color=#000000&gt;&lt;font face="Courier New"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;ProjectTracker.Library.Security.PTPrincipal.Login("pm",
"pm");&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=Code style="MARGIN: 0in 0in 0pt 0.1in"&gt;
&lt;o:p&gt;
&lt;font face="Courier New" color=#000000&gt;&amp;nbsp;&lt;/font&gt;
&lt;/o:p&gt;
&lt;/p&gt;
&lt;p class=Code style="MARGIN: 0in 0in 0pt 0.1in"&gt;
&lt;font color=#000000&gt;&lt;font face="Courier New"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;//
execute workflow&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=Code style="MARGIN: 0in 0in 0pt 0.1in"&gt;
&lt;font color=#000000&gt;&lt;font face="Courier New"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;instance.Start();&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;div style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 1pt; MARGIN-LEFT: 0.1in; BORDER-LEFT: medium none; MARGIN-RIGHT: 0in; PADDING-TOP: 0in; BORDER-BOTTOM: windowtext 1pt solid; mso-element: para-border-div; mso-border-bottom-alt: solid windowtext .5pt"&gt;
&lt;p class=CodeLast style="MARGIN: 0in 0in 12pt"&gt;
&lt;font color=#000000&gt;&lt;font face="Courier New"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;/div&gt;
&lt;p class=MsoBodyText style="MARGIN: 0in 0in 6pt"&gt;
&lt;font face="Times New Roman" color=#000000 size=3&gt;Notice that the &lt;/font&gt;&lt;span class=CodeInline&gt;&lt;span style="FONT-SIZE: 9pt; mso-bidi-font-size: 10.0pt; mso-bidi-font-family: 'Times New Roman'"&gt;&lt;font face="Courier New" color=#008000&gt;WorkflowRuntime&lt;/font&gt;&lt;/span&gt;&lt;/span&gt;&lt;font face="Times New Roman" color=#000000 size=3&gt; object
is no longer in a &lt;/font&gt;&lt;span class=CodeInline&gt;&lt;span style="FONT-SIZE: 9pt; mso-bidi-font-size: 10.0pt; mso-bidi-font-family: 'Times New Roman'"&gt;&lt;font face="Courier New" color=#008000&gt;using&lt;/font&gt;&lt;/span&gt;&lt;/span&gt;&lt;font face="Times New Roman" color=#000000 size=3&gt; block,
so it can remain in memory, not disposed, while the workflow instance is running on
the background thread.&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoBodyText style="MARGIN: 0in 0in 6pt"&gt;
&lt;font face="Times New Roman" color=#000000 size=3&gt;The workflow instance is created
the same as before, and its &lt;/font&gt;&lt;span class=CodeInline&gt;&lt;span style="FONT-SIZE: 9pt; mso-bidi-font-size: 10.0pt; mso-bidi-font-family: 'Times New Roman'"&gt;&lt;font face="Courier New" color=#008000&gt;Start()&lt;/font&gt;&lt;/span&gt;&lt;/span&gt;&lt;font face="Times New Roman" color=#000000 size=3&gt; method
is called. At that point this method simply ends, returning to the caller.&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoBodyText style="MARGIN: 0in 0in 6pt"&gt;
&lt;font face="Times New Roman" color=#000000 size=3&gt;Once you call &lt;/font&gt;&lt;span class=CodeInline&gt;&lt;span style="FONT-SIZE: 9pt; mso-bidi-font-size: 10.0pt; mso-bidi-font-family: 'Times New Roman'"&gt;&lt;font face="Courier New" color=#008000&gt;BeginWorkflow()&lt;/font&gt;&lt;/span&gt;&lt;/span&gt;&lt;font face="Times New Roman" color=#000000 size=3&gt; the
workflow is started on a background thread, but your current thread (often the UI
thread) is free to continue working.&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoBodyText style="MARGIN: 0in 0in 6pt"&gt;
&lt;font face="Times New Roman" color=#000000 size=3&gt;The final piece to the puzzle is
a method your application can call before it exits, or when it otherwise can’t continue
without the workflow having completed:&lt;/font&gt;
&lt;/p&gt;
&lt;div style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN-LEFT: 0.1in; BORDER-LEFT: medium none; MARGIN-RIGHT: 0in; PADDING-TOP: 1pt; BORDER-BOTTOM: medium none; mso-element: para-border-div; mso-border-top-alt: solid windowtext .5pt"&gt;
&lt;p class=CodeFirst style="MARGIN: 12pt 0in 0pt"&gt;
&lt;font color=#000000&gt;&lt;font face="Courier New"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;public
static void EndWorkflow()&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;/div&gt;
&lt;p class=Code style="MARGIN: 0in 0in 0pt 0.1in"&gt;
&lt;font color=#000000&gt;&lt;font face="Courier New"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=Code style="MARGIN: 0in 0in 0pt 0.1in"&gt;
&lt;font color=#000000&gt;&lt;font face="Courier New"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;//
wait for workflow to complete&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=Code style="MARGIN: 0in 0in 0pt 0.1in"&gt;
&lt;font color=#000000&gt;&lt;font face="Courier New"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;_waitHandle.WaitOne();&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=Code style="MARGIN: 0in 0in 0pt 0.1in"&gt;
&lt;o:p&gt;
&lt;font face="Courier New" color=#000000&gt;&amp;nbsp;&lt;/font&gt;
&lt;/o:p&gt;
&lt;/p&gt;
&lt;p class=Code style="MARGIN: 0in 0in 0pt 0.1in"&gt;
&lt;font color=#000000&gt;&lt;font face="Courier New"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;//
dispose runtime&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=Code style="MARGIN: 0in 0in 0pt 0.1in"&gt;
&lt;font color=#000000&gt;&lt;font face="Courier New"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;_workflowRuntime.Dispose();&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=Code style="MARGIN: 0in 0in 0pt 0.1in"&gt;
&lt;o:p&gt;
&lt;font face="Courier New" color=#000000&gt;&amp;nbsp;&lt;/font&gt;
&lt;/o:p&gt;
&lt;/p&gt;
&lt;p class=Code style="MARGIN: 0in 0in 0pt 0.1in"&gt;
&lt;font color=#000000&gt;&lt;font face="Courier New"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;if
(_workflowError != null)&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=Code style="MARGIN: 0in 0in 0pt 0.1in"&gt;
&lt;font color=#000000&gt;&lt;font face="Courier New"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/span&gt;throw
_workflowError;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;div style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 1pt; MARGIN-LEFT: 0.1in; BORDER-LEFT: medium none; MARGIN-RIGHT: 0in; PADDING-TOP: 0in; BORDER-BOTTOM: windowtext 1pt solid; mso-element: para-border-div; mso-border-bottom-alt: solid windowtext .5pt"&gt;
&lt;p class=CodeLast style="MARGIN: 0in 0in 12pt"&gt;
&lt;font color=#000000&gt;&lt;font face="Courier New"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;/div&gt;
&lt;p class=MsoBodyText style="MARGIN: 0in 0in 6pt"&gt;
&lt;font face="Times New Roman" color=#000000 size=3&gt;It is important to realize that
this method will block the current thread until &lt;/font&gt;&lt;span class=CodeInline&gt;&lt;span style="FONT-SIZE: 9pt; mso-bidi-font-size: 10.0pt; mso-bidi-font-family: 'Times New Roman'"&gt;&lt;font face="Courier New" color=#008000&gt;_waitHandle&lt;/font&gt;&lt;/span&gt;&lt;/span&gt;&lt;font face="Times New Roman" color=#000000 size=3&gt; is
set. If the workflow completes before this method is called, then &lt;/font&gt;&lt;span class=CodeInline&gt;&lt;span style="FONT-SIZE: 9pt; mso-bidi-font-size: 10.0pt; mso-bidi-font-family: 'Times New Roman'"&gt;&lt;font face="Courier New" color=#008000&gt;_waitHandle&lt;/font&gt;&lt;/span&gt;&lt;/span&gt;&lt;font face="Times New Roman" color=#000000 size=3&gt; is
already set, and this method runs immediately, but if the workflow is still running,
this method will block until the workflow completes or terminates.&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoBodyText style="MARGIN: 0in 0in 6pt"&gt;
&lt;font face="Times New Roman" color=#000000 size=3&gt;For this to work, you &lt;i style="mso-bidi-font-style: normal"&gt;must&lt;/i&gt; call &lt;/font&gt;&lt;span class=CodeInline&gt;&lt;span style="FONT-SIZE: 9pt; mso-bidi-font-size: 10.0pt; mso-bidi-font-family: 'Times New Roman'"&gt;&lt;font face="Courier New" color=#008000&gt;EndWorkflow()&lt;/font&gt;&lt;/span&gt;&lt;/span&gt;&lt;font face="Times New Roman" color=#000000 size=3&gt; before
your process terminates to properly dispose the runtime and to determine if the workflow
terminated unexpectedly.&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=945f9740-c5fb-4c34-8207-b4ca00e6c21c" /&gt;</description>
      <comments>http://www.lhotka.net/weblog/CommentView,guid,945f9740-c5fb-4c34-8207-b4ca00e6c21c.aspx</comments>
      <category>CSLA .NET</category>
      <category>Workflow</category>
    </item>
  </channel>
</rss>