I'm using google drive API in a multi-thread C# application. I would like to know if the Google dot net client library it's thread-safe or not.
Also I would like to know what's more right:
create a singelton service, or a new service every time.
I'm using google drive API in a multi-thread C# application. I would like to know if the Google dot net client library it's thread-safe or not.
Also I would like to know what's more right:
create a singelton service, or a new service every time.
If you are asking if the Google .net client Library is thread safe. I am pretty sure that it is. It is noted in at least one place in the documentation that it is thread safe.
Google APIs Client Library for .NET
UserCredential is a thread-safe helper class for using an access token to access protected resources. An access token typically expires after 1 hour, after which you will get an error if you try to use it.
It isn't. I've tried writing some code assuming it was, and my code would sometimes randomly crash at the "request.Execute()"s...
I tried using a mutex and so only one thread was using a singleton service at a time: that reduced the crashes but it didn't eliminate them.
Leaving the mutex in, I changed it to a singleton UserCredential and use a new service for each thread and it hasn't crashed since. (I don't know if I need the mutex anymore or not, but the google api calls aren't critical path for my application, I just needed to get the calls out of the main thread.)