Suspend() of persisted instance in a running state

Locked Suspend() of persisted instance in a running state

  • jueves, 07 de julio de 2011 11:27
     
     

    I have a problem with the WorkflowInstance.Suspend() method .

    If I have an instance which is in Running status , and is  persisted in the DB ( this situation can be caused by aborting the instance for example )

    I call WorkflowInstance.Suspend() on that instance .

    My expectation is the instance will remain in the same activity where it was persisted to the DB , but will be suspended now .

    The problem is that sometimes it works , but sometimes what happens is that the instance performs few activities that are right after the persistence point and only  then becomes suspended .

     

    It is a non-consistent behavior .

     

    As I understand ( with a help of a Reflector ) the following happens :

    In order to suspend the instance , the runtime loads it first and then makes it suspended.

    But since it loads it and it is in a Running state - it just continues it's execution , and then calls suspend .

    Sometimes the suspend called immediately , but sometimes the runtime succeeds to execute few activities before suspend called .

    Probably because the things there run on different threads.

     

    Anyone has a solution !?!?!?!?!

    Thanks

     

Todas las respuestas

  • martes, 04 de octubre de 2011 19:47
    Moderador
     
     

    What if you configured a WorkflowRuntime with the ManualWorkflowSchedulerService? You could then load a persisted workflow instance, and then suspend it, without it getting started up again. If you didn't call RunWorkflow then the next activities would not get started. I can put together some quick code to verify this, and also show how to use the ManualWorkflowSchedulerService if you are not familiar with it. But it should give the desired behavior.

    Thanks,

    Steve Danielson [Microsoft]
    This posting is provided "AS IS" with no warranties, and confers no rights.
    Use of included script samples are subject to the terms specified at http://www.microsoft.com/info/cpyright.htm