简体   繁体   中英

Single instance of IOrganizationService for microsoft dynamics crm

i am using Microsoft Dynamics CRM in Web API project, currently i am creating new instance of IOrganizationService on every new request,

my question is, What if i create single static instance of IOrganizationService in Global.asax's Application_Start() method and use it for each request, is it good or bad ?

thank you

The IOrganizationService is not thread safe. Putting it in a static variable in an ASP.NET web app without addressing the thread safety is probably a bad idea, for this reason alone.

Do ASP.NET developers really need to be concerned with thread safety?

The XrmLibrary includes a thread safe singleton that can be used to get instances of 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