Async plugin execution order RRS feed

  • Question

  • Hi All:

    I have a plugin registered for the create/update/delete of some entities. And these steps are in Asynch mode.

    Now, let's take lead as an example:

    If I create a lead, then update it, then delete it. Here comes my question:

    1)Is the order of system job guaranteed? Say, it will be created, update and then delete in system job?

    2)Is the execution order guaranteed? Say, it execute in a way that update will execute after created, and delete will execute after update?

    3)Is the finish time guaranteed? Say, create will finish first and delete finish last?


    Wednesday, May 7, 2014 10:05 PM

All replies

  • Async processes are created and run under the same thread (unless CRM detects a blocking issue, then it may spawn a new thread).  If all your operations are performed in the same plugin or workflow, they will be performed in the order you define there.  This is not necessarily true if some of your operations are performed within plugins or workflows on other related entities.  In that case you will have to implement some mechanism to check for the proper order of execution before actual execution.
    Friday, May 9, 2014 2:18 PM
  • Thanks for the answer JBlaeske.

    Now if I have different plugins, say one for update and one for delete. And now I update one record and delete it. Because plugin for update will take extra time to execute, it actually will be finished later then delete, right?

    And also plugin related async operations are not applicable for ordering (http://msdn.microsoft.com/en-us/library/gg327994.aspx). So it's always risky to make plugin operations async.

    That's what I currently think of this issue.

    Friday, May 9, 2014 10:48 PM
  • Hi,

    There really isn't any guarantee of the order that an async operation will run in since they are picked up by the AsyncServer and executed by a thread pool (size defined in the registry). In a multiple AsyncServer scenario, these may even been running on different servers but there will always be a degree of parallelism. If you need to guarantee a specific order, then you'll need to create a semaphore by way of a value set on a record that is waited for by another process/plugin.

    Hope this helps,


    Scott Durow
    Blog www.develop1.net    Follow Me
    If this post answers your question, please click "Mark As Answer" on the post and "Mark as Helpful"

    Sunday, May 11, 2014 9:42 AM