0
votes

Is the Graph dotNet sdk implemented Thread-Safe in all Areas?

E.g. Multiple Worker Threads want to retrieve user EMails:

var request = graphClient.Users[usrId].Messages.Request().Top(top).Select(select).Skip(10);
var result = await request.GetAsync();

Sending/executing Requests should be Thread-Safe as each of them is exceuted in their own task. But Is the creation of Requests implemented Thread-Safe?

So my Questions are

  • Is the creation of Requests in sdk Thread-Safe?
  • and Is the access to the graph client instance Thread-Safe?
1

1 Answers

2
votes

No, the .Net Graph Client library is not implemented thread-safe in all areas. From a quick review of the library code, the BaseClient baseUrl is settable which could enable a scenario where two threads are accessing that variable. This could result in requests being made to unexpected baseUrls. Once a request has been built past the baseUrl provided by the GraphServiceClient, the creation of request is expected to be thread safe.

Regarding access to the Graph client instance and thread safety, if I understand correctly, that is a matter of how you design your application's access to the library.