<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:copyright="http://blogs.law.harvard.edu/tech/rss" xmlns:image="http://purl.org/rss/1.0/modules/image/">
    <channel>
        <title>WorkFlow</title>
        <link>http://geekswithblogs.net/Shuvo/category/9573.aspx</link>
        <description>Windows Workflow Foundation</description>
        <language>en-US</language>
        <copyright>Tanveer-Ibn-Haresh</copyright>
        <managingEditor>ta_haresh@hotmail.com</managingEditor>
        <generator>Subtext Version 0.0.0.0</generator>
        <item>
            <title>Making sure Workflow Runtime has a single instance in the WebApplication Runtime</title>
            <link>http://geekswithblogs.net/Shuvo/archive/2009/02/04/making-sure-workflow-runtime-has-a-single-instance-in-the.aspx</link>
            <description>Source Code:MSDN&lt;br /&gt;
In previous versions, application used to get reference to Current workflowrutime by using codes like this:&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: rgb(0, 0, 255);"&gt;WorkflowRuntime workflowRuntime=WorkflowRequest.Current.WorkflowRuntime;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
But with 3.5 web applications use application object to store the workflowRuntime when the application starts and disposes of the runtime instance when the application stops. Global.asax file is used to hook the application_start and Application_End Event.&lt;br /&gt;
&lt;br /&gt;
Here is how it is done:&lt;br /&gt;
&lt;br /&gt;
void Application_Start(object sender, EventArgs e) &lt;br /&gt;
{&lt;br /&gt;
    System.Workflow.Runtime.WorkflowRuntime workflowRuntime =&lt;br /&gt;
        new System.Workflow.Runtime.WorkflowRuntime();&lt;br /&gt;
&lt;br /&gt;
    System.Workflow.Runtime.Hosting.ManualWorkflowSchedulerService manualService =&lt;br /&gt;
        new System.Workflow.Runtime.Hosting.ManualWorkflowSchedulerService();&lt;br /&gt;
    workflowRuntime.AddService(manualService);&lt;br /&gt;
    &lt;br /&gt;
    workflowRuntime.StartRuntime();&lt;br /&gt;
&lt;br /&gt;
    Application["WorkflowRuntime"] = workflowRuntime;           &lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void Application_End(object sender, EventArgs e) &lt;br /&gt;
{&lt;br /&gt;
    System.Workflow.Runtime.WorkflowRuntime workflowRuntime =&lt;br /&gt;
        Application["WorkflowRuntime"] as System.Workflow.Runtime.WorkflowRuntime;&lt;br /&gt;
    workflowRuntime.StopRuntime();&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
This workFlowRuntime instance remains in the application object as long as the webapplication handles requests.&lt;br /&gt;
Here is how you can how to retrieve this workflow runtime instance from the application object and star a workflow successfully. &lt;br /&gt;
&lt;br /&gt;
protected void StartRuntime_Click(object sender, EventArgs e)&lt;br /&gt;
{&lt;br /&gt;
    WorkflowRuntime workflowRuntime = Application["WorkflowRuntime"] as WorkflowRuntime;&lt;br /&gt;
    ManualWorkflowSchedulerService manualScheduler = &lt;br /&gt;
        workflowRuntime.GetService(typeof(ManualWorkflowSchedulerService)) &lt;br /&gt;
        as ManualWorkflowSchedulerService;&lt;br /&gt;
&lt;br /&gt;
    WorkflowInstance instance = workflowRuntime.CreateWorkflow(&lt;br /&gt;
        typeof(ASPNetSequentialWorkflow));&lt;br /&gt;
    instance.Start();&lt;br /&gt;
    manualScheduler.RunWorkflow(instance.InstanceId);&lt;br /&gt;
} &lt;img src="http://geekswithblogs.net/Shuvo/aggbug/129183.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Shuvo</dc:creator>
            <guid>http://geekswithblogs.net/Shuvo/archive/2009/02/04/making-sure-workflow-runtime-has-a-single-instance-in-the.aspx</guid>
            <pubDate>Wed, 04 Feb 2009 18:49:41 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/Shuvo/comments/129183.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/Shuvo/archive/2009/02/04/making-sure-workflow-runtime-has-a-single-instance-in-the.aspx#feedback</comments>
            <slash:comments>39</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/Shuvo/comments/commentRss/129183.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Workflow Essentials</title>
            <link>http://geekswithblogs.net/Shuvo/archive/2009/02/03/workflow-essentials.aspx</link>
            <description>Source: MSDN&lt;br /&gt;
Things you should know before working on Workflow.&lt;br /&gt;
&lt;br /&gt;
***   A workflow built on Windows Workflow Foundation is a component that requires an  ad hoc runtime environment to function. The workflow runtime environment is  represented by the WorkflowRuntime class. To host a workflow library, you create  and configure an instance of the WorkflowRuntime class to operate on a  particular workflow type. For performance reasons, you normally create the  runtime environment only once in the application lifetime and make it serve all  incoming requests. In a Windows Forms application, you initialize the workflow  runtime in the form's constructor and destroy it with the form when the  application shuts down. &lt;img src="http://geekswithblogs.net/Shuvo/aggbug/129165.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Shuvo</dc:creator>
            <guid>http://geekswithblogs.net/Shuvo/archive/2009/02/03/workflow-essentials.aspx</guid>
            <pubDate>Tue, 03 Feb 2009 18:59:25 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/Shuvo/comments/129165.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/Shuvo/archive/2009/02/03/workflow-essentials.aspx#feedback</comments>
            <slash:comments>9</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/Shuvo/comments/commentRss/129165.aspx</wfw:commentRss>
        </item>
    </channel>
</rss>
