Efficient use of PNP CSOM Core C#

Occasional Visitor

I'm currently working through methods by which to make usage of PNP CSOM core more efficient on a large project that is expected to have loads of concurrent connections to and requests made of a SharePoint Online tenant.  As I understand it, the thing I want to cut down on the most is ExecuteQueryAsync calls followed by calls to create ClientContext.  


One thing I was looking into is creating ClientContext as a singleton, but in my research I've found that ClientContext isn't threadsafe, so that looks like it would eliminate that as an option.  Has anyone been able to successfully do this?


Here are some resources I've come across:





We have two main classes that handle SharePoint calls, and they currently have ClientContext created in several public methods.  My plan is to create one ClientContext per class vs several. 


I'm posting this to see what has worked for other folks,  what patterns have been used successfully and which have not etc.  

0 Replies