Search code examples
c#lockingunmanagedmanaged

Is locking required on managed code with no data structure of it's own?


My .net library is just a wrapper around unmanaged c++ library. Unmanaged C++ library has ensured thread safety measures. Do I need to lock or provide thread safety code in .net space which has no data structures of it's own?

Are there any side effects of not providing thread safety in .net space? .Net library is expected to be used in multi-threaded environment.


Solution

  • If the code you're calling is thread safe, then the code which calls your thread safe code is in turn thread safe, assuming that it does not maintain state of any kind. If it's merely a pass-through then you should be all set.