My desktop .NET 3.5 application uses WebRequest.BeginGetResponse
to issue a request which is used to implement long polling. This request typically takes 10 seconds or more to process. The trouble is BeginGetResponse
performs the waiting for the request to complete on the thread pool, which then seems to be starving. Is there some way how to specify a custom thread or a custom thread for BeginGetResponse
to use?
As an alternative I could also use my own thread performing synchronous request using WebRequest.GetResponse
(hopefully this is really synchronous in .NET 3.5, it was not in .NET 1.0), but then I have a problem I am unable to terminate the request prematurely when I need to quit the application, as I see no clean way how to abort a synchronous request.