Multithreaded PinVoked DLL in a managed environment. Is it possible?

I have Vendor.DLL (a native DLL written in C ++) that provides many methods. Usually, Vendor.DLL opens its own Vendor files, returns descriptors, and allows more read / write operations for these files. Vendor.DLL supports multithreading (when called from unmanaged code / COM).

If I expose the Pinvoked method from the Vendor DLL, let's say

PinvokedVendor.DLL

[System.Runtime.InteropServices.DllImportAttribute("Vendor.dll", EntryPoint = "SomeVendorMethod")]
            public static extern int SomeVendorMethod(uint param1, ref SomeVendorDataStruct pData);

How to ensure that this wrapper class is thread safe? Is it even thread safe when called from ASP.NET? What are my options?

Thanks in advance.

+3
source share
3 answers

. DLL . P-Invoke .

+4

vendor.dll, PInvoke , . . , PInvoke , . , , , , vendor.dll

0

[MTAThread] [STAThread] pinvoke threading COM? ...

, , , .

0

Source: https://habr.com/ru/post/1730568/


All Articles