c# - Web Api 项目中的 CrmServiceClient 重用或连接池

标签 c# .net dynamics-crm-2011 dynamics-crm

我想了解如何在 Web Api 项目中使用 CRM SDK 的 CrmServiceClient,并想确认我的理解是否正确。

CrmServiceClient实现连接池是真的吗?如果是这样,那么简单地为每个 Web 请求创建一个新实例是否有效,因为创建新连接的开销将被 CrmServiceClient 减轻?

或者我应该在整个应用程序中使用 CrmServiceClient 的单个实例吗?我认为这行不通,因为我的理解是它不是线程安全的,最终连接将关闭(我认为)。

最佳答案

它在 documentation for CrmServiceClient 中说:

Thread Safety
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

(强调我自己)

当然,我在整个应用程序中都使用了 CrmServiceClient 的一个静态实例,而且从未遇到过问题。

关于c# - Web Api 项目中的 CrmServiceClient 重用或连接池,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41272005/

相关文章:

c# - 如何从另一个窗体编辑数据库 C#

c# - ASP.NET 身份 - 简化

c# - 如何将 SVG 文件转换为 WMF 格式?

html - MongoDB,为博客应用程序存储带图像的格式化文本的方式

c# - Google 应用程序引擎 ASP.net

dynamics-crm-2011 - 客户关系管理 2011 和 typescript : How to get sections within a tab

database - crm 2011 更改 30K 记录的所有者

c# - 我有两个问题,其中一个是正则表达式

c# - 如何从resx中的ImageListStreamer中获取图像文件?

javascript - CRM 2011 HTML 网络资源 : getContext produces "Object doesn' t support property or method"