在此链接上:https://azure.microsoft.com/en-us/documentation/articles/app-insights-api-custom-events-metrics/
它明确表示:
TelemetryClient is thread-safe.
We recommend you use an instance of TelemetryClient for each module of your app.
但是,MSDN 文档 ( https://msdn.microsoft.com/en-us/library/azure/microsoft.applicationinsights.telemetryclient.aspx ) 说:
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
所以问题是,大多数函数(例如 TrackEvent 和 TrackMetric)都不是静态的。如果我遵循第一篇文章,为我的 Web 服务拥有一个单例实例,我会遇到线程问题吗?
最佳答案
TelemetryClient 是线程安全的。有效的用法是创建一个单例并重用它。您不会遇到重用实例的问题。
关于c# - Application Insight 的 TelemetryClient 线程安全吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37689339/