microsoft / PowerPlatform-DataverseServiceClient

Code Replica for Microsoft.PowerPlatform.Dataverse.Client and supporting nuget packages.
MIT License
284 stars 52 forks source link

Multi threaded client management recommendations@heroes3lover #415

Closed tdahnert closed 11 months ago

tdahnert commented 1 year ago

Do you have any code samples on best practices for reusing service client in an async azure function that is multithreaded? I’ve been looking for best practices for a while.

For the new Service Client, our recommendation has changed from using .Clone to using the Async versions of the primary messages if you're working with a multithreaded application.

Originally posted by @MattB-msft in https://github.com/microsoft/PowerPlatform-DataverseServiceClient/issues/78#issuecomment-1369139060

MattB-msft commented 11 months ago

The DVSC is Thread safe and is safe to use across multiple threads from one client as long as you're using the Async Methods. We do have a work item to document a Dependency injection pattern but it's just not 'got there' yet in the things that various teams are doing.

Right now, the closest we have documented to this has to do with data import, which you can see here: https://learn.microsoft.com/en-us/power-apps/developer/data-platform/send-parallel-requests?tabs=sdk#examples