fiskaly / fiskaly-sdk-dotnet

fiskaly Cloud-TSE SDK for .NET and Xamarin
https://developer.fiskaly.com
MIT License
6 stars 4 forks source link

Is the FiskalyHttpClient.Request() method thread safe? #25

Closed HeadOnBenni closed 4 years ago

HeadOnBenni commented 4 years ago

Hello,

I am currently using the .NET SDK to send requests to Fiskaly from a mutlithreaded program. In the example on your GitHub page, you are using the client in a static variable, but I can't quite deduce from the source code whether the FiskalyHttpClient or the FiskalyHttpClient's request method is really thread safe. Could you please help me here?

Thanks in advance.

auxdevelopment commented 4 years ago

Hi!

Currently the .NET SDK is not intended for use in a multi-threaded environment.

HeadOnBenni commented 4 years ago

Hi @auxdevelopment ,

thanks for the feedback. Does this mean that if I create a separate instance for each thread, no problems will occur? Or is the fiskaly-client.dll not thread safe and I have to make sure that this dll is never accessed simultaneously?

Thanks for your support!

auxdevelopment commented 4 years ago

Hi!

Regarding the SDK this wouldn't be an issue.

The real issue would be a different one though because you cannot (to my knowledge at least) load a static library (the DLL) into a process more often than once. Because the SDK implicitly tries to load the client library, your approach would lead to an error.

HeadOnBenni commented 4 years ago

Hi @auxdevelopment ,

thanks for the feedback. Since the Windows client does the import via a static instance variable, the DLL is loaded only once, as far as I know. Therefore several instances would access the "same" DLL. Can the DLL handle multiple threads accessing it at the same time? Or exactly is the code inside the "com.fiskaly.client-windows-amd64-v1.2.000.dll" thread safe?

auxdevelopment commented 4 years ago

Hello,

in that case accessing the library from multiple threads shouldn't be an issue.