{"id":1353,"date":"2010-06-15T23:00:15","date_gmt":"2010-06-16T06:00:15","guid":{"rendered":"https:\/\/mathpirate.net\/log\/?p=1353"},"modified":"2010-06-15T23:00:15","modified_gmt":"2010-06-16T06:00:15","slug":"windows-workflow-quick-tip","status":"publish","type":"post","link":"https:\/\/mathpirate.net\/log\/2010\/06\/15\/windows-workflow-quick-tip\/","title":{"rendered":"Windows Workflow Quick Tip"},"content":{"rendered":"<p>Given that I spent\u00c2\u00a0all\u00c2\u00a0day looking for this and had trouble finding it (Okay, I&#8217;ll be honest, I skipped a page in the book because it didn&#8217;t look relevant, but whatever), if you ever need to get the name of the currently executing state on a Windows Workflow (WF) State Machine Workflow, there&#8217;s a class you can use called StateMachineWorkflowInstance.\u00c2\u00a0 StateMachineWorkflowInstance has a property called CurrentStateName to give you the name as a string and another called CurrentState, which gives you an instance of the StateActivity object that&#8217;s currently running.<\/p>\n<p>For some reason unknown to me, StateMachineWorkflowInstance isn&#8217;t derived from WorkflowInstance ((Cause, you know, .Net is all object orienty and such, so that&#8217;s what I would&#8217;ve done&#8230;)), so the WorkflowInstance you get back from WorkflowRuntime.CreateWorkflow can&#8217;t be cast to a StateMachineWorkflowInstance instance.\u00c2\u00a0 Instead, you have to new up the object yourself.\u00c2\u00a0 The constructor takes the WorkflowRuntime where the workflow is executing, and the Guid returned by the InstanceId property on the WorkflowInstance that was returned by CreateWorkflow for the workflow you want to know the state for.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Given that I spent\u00c2\u00a0all\u00c2\u00a0day looking for this and had trouble finding it (Okay, I&#8217;ll be honest, I skipped a page in the book because it didn&#8217;t look relevant, but whatever), if you ever need to get the name of the currently executing state on a Windows Workflow (WF) State Machine Workflow, there&#8217;s a class you [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[7],"tags":[10,237,144,143,145],"_links":{"self":[{"href":"https:\/\/mathpirate.net\/log\/wp-json\/wp\/v2\/posts\/1353"}],"collection":[{"href":"https:\/\/mathpirate.net\/log\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mathpirate.net\/log\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mathpirate.net\/log\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/mathpirate.net\/log\/wp-json\/wp\/v2\/comments?post=1353"}],"version-history":[{"count":1,"href":"https:\/\/mathpirate.net\/log\/wp-json\/wp\/v2\/posts\/1353\/revisions"}],"predecessor-version":[{"id":1354,"href":"https:\/\/mathpirate.net\/log\/wp-json\/wp\/v2\/posts\/1353\/revisions\/1354"}],"wp:attachment":[{"href":"https:\/\/mathpirate.net\/log\/wp-json\/wp\/v2\/media?parent=1353"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mathpirate.net\/log\/wp-json\/wp\/v2\/categories?post=1353"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mathpirate.net\/log\/wp-json\/wp\/v2\/tags?post=1353"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}