I have a Dynamic CRM plugin which has two steps. One is running on pre-create and second is running on post-create. I have used Shared Variables. I am setting the values in shared variables on pre-create and retriving the values on post-create.
Now is it thread safe. If two users trigger the same plugin in same org would not they over write each others data?
Set values in Shared Variables:
context.SharedVariables.Add("statecode", stateCodeValue);
context.SharedVariables.Add("statuscode", statusCodeValue);
Get values from Shared Variables:
int statecode = (int)context.SharedVariables["statecode"];
int statuscode = (int)context.SharedVariables["statuscode"];
Yes, this is thread-safe. The IPluginExecutionContext
passed to your plugin class is an object that is uniquely created for a plugin execution pipeline. Shared variables are passed from one stage to the next (PreValidation => PreOperation => PostOperation => AsyncOperation).
An execution pipeline is specific for any single operation processed by the CRM platform. (Eg a create or update message regarding a specific record.)
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.