pnpframework
pnpframework copied to clipboard
Clarification Needed: Thread-Safety of AuthenticationManager.GetACSAppOnlyContext
Trying to understand whether we can reuse a single ClientContext instance to run some operations through multiple threads, such as uploading many files, where we run await clientContext.ExecuteQueryRetryAsync();
.
Would you please help clarify the thread safety of type PnP.Framework.AuthenticationManager
and type Microsoft.SharePoint.Client.ClientContext
?
For multi-threaded scenarios,
Should I call below line to create new AuthenticationManager
instance and get new ClientContext
every time?
new AuthenticationManager().GetACSAppOnlyContext(this.SiteUrl, appClientId, appSecret);
Or can we use a singleton of AuthenticationManager
or even ClientContext
? not sure whether there is some caching done when I call GetACSAppOnlyContext
first time for reuse for later calls.
Fast forward 7 months and I stumbled onto this thread looking for the same advice. What did you end up doing?