Unloading Instances

Although there are specific times WF will unload and persist your workflow instance, in some cases you might want to take control of that yourself. For those situations, WorkflowInstance.Unload and WorkflowInstance.TryUnload are there to help.

If you call either of these methods without first plugging in the SqlWorkflowPersistenceService, WF will throw an exception. Of course, if there is a database error of some kind, you’ll also receive an exception. Therefore, it’s good practice to wrap these calls in try/catch blocks to keep from crashing your entire application. (Note that’s not to say you have to do anything with the exception...sometimes you may just want to ignore it.)

Let’s try it out! In fact, let’s build a small graphical ...

Get Microsoft® Windows® Workflow Foundation Step by Step now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.