4

Are the instance methods on Microsoft.Azure.Devices.Client.DeviceClient thread-safe? For example, is it safe to have a single instance of DeviceClient, and execute its methods concurrently from multiple threads?

Our current code base makes multiple concurrent calls to UploadToBlobAsync(), UpdateReportedPropertiesAsync(), and SendEventAsync(), all on the same instance. The documentation does not mention thread-safety at all, but I would like to confirm if the methods are thread-safe or not before reworking our current code base to manually prevent concurrent access to the instance methods.

Timothy
  • 41
  • 1

1 Answers1

0

Yes, DeviceClient is thread-safe, according to https://github.com/Azure/azure-iot-sdk-csharp/issues/1613. So you can safely call any instance methods in parallel using just one instance of DeviceClient.

Mo B.
  • 5,307
  • 3
  • 25
  • 42