简体   繁体   English

适用于Microsoft Dynamics CRM的IOrganizationService的单个实例

[英]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, 我在Web API项目中使用Microsoft Dynamics CRM,目前我在每个新请求上创建IOrganizationService的新实例,

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 ? 我的问题是,如果我在Global.asax的Application_Start()方法中创建IOrganizationService的单个静态实例并将其用于每个请求该怎么办?

thank you 谢谢

The IOrganizationService is not thread safe. IOrganizationService不是线程安全的。 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. 仅出于这个原因,将其放在ASP.NET Web应用程序中的静态变量中而不解决线程安全性可能是一个坏主意。

Do ASP.NET developers really need to be concerned with thread safety? ASP.NET开发人员真的需要关心线程安全吗?

The XrmLibrary includes a thread safe singleton that can be used to get instances of IOrganizationService. XrmLibrary包括一个线程安全的单例,可用于获取IOrganizationService的实例。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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