Skip to main content

Dears,


Can you please help us with the following issue; as we face a delay when trying  to open a task has been just started using "SourceCode.Workflow.Client" API, then retrieve directly  the work list items related to started process id, unfortunately we have to sleep the code 3-5 seconds as below pseudo code describe ...

can any help? kindly note, that below code retrieve the tasks correctly but if step "3" -thread sleeping- has been removed empty task list would be retrieved.


----------------------------------------------------------------------------------------------------------------------------------------


pseudo code:


1. start a process instance.


2. save started instance id in " id" integer variable.


3. sleep the thread for 5 seconds.


4. prepare WorkListCriteria to filter by processID.


5. Open work list item, using previous filter  to retrieve tasks related to started process instance in step (1).


-------------------------------------------------------------------------------------------------------------------------------------------



When you call the StartProcessInstance method, you have an option to start it Synchronously or Asynchronously. The difference is:



  • Synchronous: The process will start, but focus will not be returned to the caller until it hits an async event (like a client event). This is what you require.
  • Asynchronous: The process is started but focus is returned as soon as the creation is completed. This is why you need the waiting period, the K2 server is still routing the process through the relevant paths. This is also the default behavior if you do not set the parameter in the method mentioned.

Change your code to StartProcessInstance(K2Proc, true)


That should resolve your issues.


Thanks


Reply