pnpframework icon indicating copy to clipboard operation
pnpframework copied to clipboard

Clarification Needed: Thread-Safety of AuthenticationManager.GetACSAppOnlyContext

Open dawwa opened this issue 3 years ago • 1 comments

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.

dawwa avatar Aug 06 '21 21:08 dawwa

Fast forward 7 months and I stumbled onto this thread looking for the same advice. What did you end up doing?

improving-jeffd avatar Mar 16 '22 19:03 improving-jeffd