I have created an ASP 3.5 web service which performs thumbnail generation using some Windows APIs. These APIs use Windows HANDLE
orHFILE
for processing. I am using Asynchronous AJAX in JavaScript to call the web-service.
When I am initiating only 1 request i.e. single thread in web service, no error is coming, but
When I am initiating multiple requests i.e. multiple threads in web service, internal APIs listed below are giving errors randomly without any specific patterns. GetLastError
returns error code 0x00000006
.
Internal APIs: One Set
_llseek
_lread
Second Set
CreateFileMapping
MapViewOfFile
Notes:
_llseek
and _lread
use HANDLE
created using
CreateFile(str, 0x80000000, 0x00000001, IntPtr.Zero, 3, 1, IntPtr.Zero)
CreateFileMapping
and MapViewOfFile
use HANDLE
created using,
CreateFile(sThumbnailFile, (uint)(0x80000000 | 0x40000000), 0, IntPtr.Zero, 2, 128, IntPtr.Zero);
no error or INVALID_HANDLE_VALUE
return code is coming while creating HANDLE
.
This issue is occurring randomly in multiple requests.
HANDLE
points to a different file.I have even tested with CRITICAL_SECTION
but issue still persists. Please suggest what could be the possible error?
I know solution would seem a little weird..but the problem was:
some other HANDLE
in some other API was being closed improperly due to which these APIs started giving error at runtime in multi-threaded environment due to shortage of memory or other resource.
Thanks.