简体   繁体   中英

CRM custom workflow, use multithreads

I want to spin off multithreading in CRM workflow. I initially use the IOrganizationService to retrieve a collection of entities. Based on the collection, I want to perform multiple action on other entities.

The problem is that I am not able to get any examples for the same. I get examples but not for anything in an CRM custom workflow. I tried Parallel.ForEach using the single IOrganizationService, creating multiple IOrganizationServices, but in all cases my workflow immediately goes into Waiting state with error thrown.

Is this possible to spin off multiple threads in an workflow. If yes can I get some pointers on this.

  • girija

CRM back-end wants to orchestrate parallel operations itself. And it makes sense since load on a servers could change dramatically, and CRM should be prepared for that.

Some parallel processing is possible, but if it's not involving IOrganizationService . It looks to be not thread-save, and sooner or later will fail if used in parallel processing.

To solve your problem, I believe you need to re-think your approach. For example you can spawn many workflow instances and let CRM deal (die, most likely) with this load or, for example, prepare data in advance and process it in parallel without need of calling IOrganizationService .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM