Skip to main content
A newer version of this page is available.

How to: Disable the Persistent Activities Recompilation on the Workflow Designer Launch

  • 3 minutes to read

The Workflow Designer supports activities that are represented by real .NET types. That is why the Workflow Module creates a new .NET type for each designed activity. The dynamic assembly which resides in memory and provides persistent activities for the designer is recompiled each time the designer is started. The dynamic assembly is loaded in the application domain, and the memory occupied by the assembly can be released only when the application is closed (in .NET, each compiled type remains in memory until the application is restarted). However, this behavior is unnecessary when all of your runtime activities are built based on compiled WF activities, and there are no reused runtime activities. In this scenario, you can disable the persistent activities recompilation and, consequently, reduce memory consumption.

Note

Mobile applications do not support the Workflow Module, so the approach described in this topic cannot be implemented in the Mobile platform.

  • Create a WinForms application using the DevExpress v19.2 XAF Solution Wizard.
  • Run the Application Designer. Drag the WorkflowWindowsFormsModule component from the Toolbox to the Modules pane.

    Workflow_AddModuleFromToolbox

    Rebuild your solution after making changes in the designer.

  • Inherit the XpoWorkflowDefinition persistent class (requires a Devexpress.ExpessApp.Workflow.v.v19.2.dll reference). In your custom descendant, override the CanCompileForDesigner property so that it always returns false.

    using DevExpress.ExpressApp.Workflow.Xpo;
    // ...
    public class MyWorkflowDefinition : XpoWorkflowDefinition {
        public MyWorkflowDefinition(DevExpress.Xpo.Session session) : base(session) { }
        public override bool CanCompileForDesigner {
            get { return false; }
        }
    }
    
  • Rebuild your solution. Run the Model Editor and navigate to the Views | MyWorkflowDefinition_DetailView | Layout node. Adjust the layout to make it similar to the base class’ layout (i.e., make the required base class’ properties visible). The image below illustrates this customization.

    PersistentActivities_Layout

  • Return to the Application Designer. In the designer’s Modules pane, focus the WorkflowModule component. In the Properties window, set the WorkflowModule.WorkflowDefinitionType property to MyWorkflowDefinition.

    PersistentActivities_DefinitionType

Now you can check the result. Run the application to see that runtime activities are not added to the Workflow Designer toolbox. As the result, the application requires less memory.

In contrast to this simple example, a real-world application will additionally include the Workflow Server Service. So, you should specify the same workflow definition type on the server side. This can be done in the OnStart method declared in the WorkflowServerService.cs (WorkflowServerService.vb), after the WorkflowServer object is instantiated.

server = new WorkflowServer("http://localhost:46232", objectSpaceProvider, objectSpaceProvider);
server.WorkflowDefinitionProvider = new WorkflowDefinitionProvider(typeof(MyWorkflowDefinition));