Microsoft.Crm.Accelerator.Cca.Samples.WorkflowManager.WorkflowManagerControl: issues with the invocation of AddServices() method inside of DoAction()

Aug 28, 2012 at 7:49 AM

Hi all.

I'm experiencing a problem during the invocation of AddServices method in the Microsoft.Crm.Accelerator.Cca.Samples.WorkflowManager.WorkflowManagerControl class and I'm hoping you can help me.

My code flow is approximately described below:

1- Invoke a workflow

2- If workflow fails:

2a- Stop its execution with status of Cancelled with LocalRefreshAfterDoneOrCancel method in the Microsoft.Crm.Accelerator.Cca.Samples.Wpf.Controls.WpfWorkflow hosted control.

2b- Force workflow to restart 

After that, the DoAction of the WorkflowManagerControl is invoked again with "Human Workflow Automation" action name and the code flow hangs in the invocation of AddServices method.

 

I inspected it with Reflector and I noticed that the code block that causes this stall is:

bool isStarted = workflowRuntime.IsStarted;

 

if (isStarted)
{
    workflowRuntime.StopRuntime();
}

 

In this second invocation the workflowRuntime results (obviously) started, therefore the code proceeds trying to execute StopRuntime() method.

Here it seems to go in stall, like if it waits for something: it doesn't throws exceptions nor goes in error state but it remains in undefined wait.

I think it's a multithreading issue but I can't understand how I could avoid this stall. 

Anyone can explain me what's happen and how can I solve this issue?

Any suggesttions?

Thanks in advance.

Daniele