In msvs 2015, the _locking function has a defect: if it is called with the _LK_NBLCK parameter, then if it is impossible to block a specified section, the function should return control. However, it performs a single wait cycle of 1000ms. In my case, this is critical (there are significant delays). Actually, the question is how to solve this problem (maybe there is a fix for the defect, or there is an opportunity to use some other function).

  • At first glance, there are three options - use another access sharing mechanism (for example, your own), use the Platform Toolset below (v100 for example), and the most confusing option is to put the dll library into a separate project for studio 2010, which will deal with working with files. - Vladimir Gamalyan
  • Indeed a bug, judging by the code in C:\Program Files (x86)\Windows Kits\10\Source\10.0.10240.0\ucrt\lowio\locking.cpp:59 . At the end of the attempt loop, Sleep(1000); worth Sleep(1000); which in any case is executed, even with one attempt. Then the fourth option is to copy the code for this lock to the project, correct and use it. - Vladimir Gamalyan
  • In 2010, the msvs of this bug is not (all the toolsets in 2015 have the same error). I thought to take the code for myself, but there are a lot of strings there - too much will have to be raked. - Anton Sobolev
  • If the code does not require c ++ 11 chips, you can put the toolset v100 in the settings, and continue to work in vs2015 (you will only need to rebuild the project once). Well, by the way, you can do a very simple dll-ku in vs2010, which will only export this one f-iy. And then use it in the main project. (Runtime will certainly be needed from both studios in the end). - Vladimir Gamalyan
  • I'll try to make my own copy of the function. The trouble is that I do not know what else there are bugs. - Anton Sobolev

0