我想了解如何在 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/