3

I'm using WinHTTP in order to create client http request. although it's working good most of the time, I have a bit of confusion regarding the thread pool Windows opens for async winhttp connections.

As written in MSDN about WinHttpSetOption function:

WINHTTP_OPTION_WORKER_THREAD_COUNT

Sets an unsigned long integer value that specifies the number of worker threads the thread pool should use for asynchronous

completions. The default value of this option is zero, which specifies that the number of worker threads is equal to the number of CPUs on the system. This option can only be set on a NULL HINTERNET handle before an asynchronous operation has occurred. This option can only be set once.

Windows Server 2008 R2 and Windows 7:  This flag is obsolete.

So, let's say I want to fire 100 asynchronous request - In my Visual Studio debugging tools I can clearly see that my app is opening 100 background threads (!). this is not scalable at all. since I target windows 7/Windows servers above 2008 and above, I can't call WinHttpSetOption with WINHTTP_OPTION_WORKER_THREAD_COUNT option.

So my question is - is there any workaround this? I would like to keep the thread count as low as possible while being able to fire many http requests asynchronously.

David Haim
  • 25,446
  • 3
  • 44
  • 78

0 Answers0