void WorkerThreadFunc() { // fire up the server, this will run as part of the service (you can set the workflow store here) IWorkflowStore workflowStore = BootStrapper.MongoDbStore(); //IWorkflowStore workflowStore = BootStrapper.MemoryStore(); //IWorkflowStore workflowStore = BootStrapper.RavenDbEmbeddedStore(); IWorkflowServer workflowServer = new WorkflowServer(workflowStore); workflowServer.RegisterWorkflowType <FileCreationWorkflow>(); // create a new example workflow if it hasn't been registered already FileCreationWorkflow workflow = new FileCreationWorkflow(FileCreationWorkflow.State.Start); workflow.RootFolder = "C:\\Temp\\"; workflow.ResumeTrigger = FileCreationWorkflow.Trigger.WriteFirstFile.ToString(); workflow.Priority = 5; workflowServer.RegisterWorkflow(workflow); while (!_shutdownEvent.WaitOne(0)) { int executedCount = 0; try { executedCount = workflowServer.ExecuteWorkflows(5); } catch (Exception) { // do some logging! } // if no workflows were found, sleepy sleep - you should create an app setting for the poll // interval appropriate to you if (executedCount == 0) { Thread.Sleep(1000); } } }
void WorkerThreadFunc() { // fire up the server, this will run as part of the service (you can set the workflow store here) //IWorkflowStore workflowStore = BootStrapper.MongoDbStore(); //IWorkflowStore workflowStore = BootStrapper.MemoryStore(); IWorkflowStore workflowStore = BootStrapper.RavenDbEmbeddedStore(); IWorkflowServer workflowServer = new WorkflowServer(workflowStore); workflowServer.RegisterWorkflowType<FileCreationWorkflow>(); // create a new example workflow if it hasn't been registered already FileCreationWorkflow workflow = new FileCreationWorkflow(FileCreationWorkflow.State.Start); workflow.RootFolder = "C:\\Temp\\"; workflow.ResumeTrigger = FileCreationWorkflow.Trigger.WriteFirstFile.ToString(); workflowServer.RegisterWorkflow(workflow); while (!_shutdownEvent.WaitOne(0)) { try { workflowServer.ExecuteWorkflows(5); } catch (Exception) { Thread.Sleep(1000); } // sleepy sleep Thread.Sleep(1000); } }