I have read lessons which have the WF setup within the Global.asax and also the lessons work. However I'm not sure the way it works inside a multi-user atmosphere. It is possible to better method of establishing this up?
Things I have finally:
'Global.asax <%@ Application Language="VB" %> <script runat="server"> Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs) ' Code that operates on application startup ' Obtain the connection string from Web.config. Dim connectionString As String = ConfigurationManager.ConnectionStrings("LocalConnection").ConnectionString ' Create the workflow runtime. Dim workflwRuntime As System.Workflow.Runtime.WorkflowRuntime = New System.Workflow.Runtime.WorkflowRuntime() ' Add the monitoring service. workflwRuntime.AddService(New System.Workflow.Runtime.Monitoring.SqlTrackingService(connectionString)) ' Add the arranging service. workflwRuntime.AddService(New System.Workflow.Runtime.Hosting.ManualWorkflowSchedulerService()) ' Add the persistence service. Dim parameters As NameValueCollection = New NameValueCollection() parameters.Add("ConnectionString", connectionString) parameters.Add("UnloadOnIdle", "true") workflwRuntime.AddService(New System.Workflow.Runtime.Hosting.SqlWorkflowPersistenceService(parameters)) ' Add the communication service. Dim dataService As System.Workflow.Activities.ExternalDataExchangeService = New System.Workflow.Activities.ExternalDataExchangeService() workflwRuntime.AddService(dataService) dataService.AddService(New WWFTestFlow.WorkflowLibrary.LoanEventService()) ' Add the shared connection service. workflwRuntime.AddService(New System.Workflow.Runtime.Hosting.SharedConnectionWorkflowCommitWorkBatchService(connectionString)) ' Start the workflow runtime. ' (The workflow runtime begins instantly when workflows are began, but ' won't start instantly when monitoring data are asked for.) workflwRuntime.StartRuntime() ' Add the runtime towards the application. Application("WorkflowRuntime") = workflwRuntime Finish Sub Sub Application_Finish(ByVal sender As Object, ByVal e As EventArgs) ' Code that operates on application shutdown Finish Sub Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs) ' Code that runs when an unhandled error happens Finish Sub Sub Session_Start(ByVal sender As Object, ByVal e As EventArgs) ' Code that runs whenever a new session is began Finish Sub Sub Session_Finish(ByVal sender As Object, ByVal e As EventArgs) ' Code that runs whenever a session finishes. ' Note: The Session_Finish event is elevated only if the sessionstate mode ' is placed to InProc within the Web.config file. If session mode is placed to StateServer ' or SQLServer, the big event isn't elevated. Finish Sub </script>