Click here to Skip to main content
15,911,531 members
Home / Discussions / C#
   

C#

 
GeneralRe: passing data from child form to parent Pin
OriginalGriff12-Dec-09 22:20
mveOriginalGriff12-Dec-09 22:20 
GeneralRe: passing data from child form to parent Pin
dan!sh 13-Dec-09 0:05
professional dan!sh 13-Dec-09 0:05 
GeneralRe: passing data from child form to parent Pin
tasumisra13-Dec-09 2:47
tasumisra13-Dec-09 2:47 
GeneralRe: passing data from child form to parent Pin
OriginalGriff13-Dec-09 2:52
mveOriginalGriff13-Dec-09 2:52 
GeneralRe: passing data from child form to parent Pin
DaveyM6913-Dec-09 4:10
professionalDaveyM6913-Dec-09 4:10 
GeneralRe: passing data from child form to parent Pin
dan!sh 13-Dec-09 5:38
professional dan!sh 13-Dec-09 5:38 
GeneralRe: passing data from child form to parent Pin
tasumisra13-Dec-09 2:45
tasumisra13-Dec-09 2:45 
QuestionHttpWebRequest.BegineGetResponse() not running asynchronously… Pin
royk12312-Dec-09 17:53
royk12312-Dec-09 17:53 
Hi,

I'm running into a very strange behavior of HttpWebRequest.BeginGetResponse().

Instead of returning immediately, and executing the request in a new Thread from the ThreadPool, the method blocks, and the request is executed in the same thread. Actually, it behaves like HttpWebRequest.GetResponse().

Basically I do a very simple task, in which I call a big number of web requests and run them asynchronously:


private void scheduleMyWebRequests()
{
    for (int i = 0; i < someNumber; i++)
    {
        // Define my HttpWebRequest here
        …
	
        IAsyncResult result = httpWebReq.BeginGetRespons(processMyData, state);

        //Register the timeout callback, since asyncronous calls ignore the WebRequests's timeout
        ThreadPool.RegisterWaitForSingleObject(result.AsyncWaitHandle, timeoutCallback, state, timeout, true);
    }
}


private void processMyData (IAsyncResult result)
{
    // Do some processing here
    ...
   // Check if all requests are finised 
    ...
    if(noMoreRequestsToProcess)
         callAnotherMethodToContinue()
}


This code works perfectly when the web requests use HttpMethod.GET
All the requests run asyncronously.

However, when I started using requests which are HttpMethod.POST something strange happens:

After the first BegineGetResponce() the control doen't return immediately.
Instead, the same thread starts runing the processMydata() method. Only when this method finishes, the control returns to the calling method.

All my web requests are performed syncronously rather then asyncronously (I've dumped the Thread's Id and all the calles use the same Thread Id).

When I use HttpMethod.Get I can see that indeed, each request uses a different Thread Id, as expected.

Does anyone have a clue why is this happening?

P.S. the cause is not an unhandled exception. I've already checked…

Tnx
Roy
AnswerRe: HttpWebRequest.BegineGetResponse() not running asynchronously… Pin
Luc Pattyn13-Dec-09 2:04
sitebuilderLuc Pattyn13-Dec-09 2:04 
GeneralRe: HttpWebRequest.BegineGetResponse() not running asynchronously… Pin
royk12314-Dec-09 0:37
royk12314-Dec-09 0:37 
Questionconnectionstring Pin
farokhian12-Dec-09 10:03
farokhian12-Dec-09 10:03 
QuestionException Handling Pin
Razanust12-Dec-09 7:53
Razanust12-Dec-09 7:53 
AnswerRe: Exception Handling Pin
PIEBALDconsult12-Dec-09 8:52
mvePIEBALDconsult12-Dec-09 8:52 
QuestionSchedulle a task for some days of the week Pin
baranils12-Dec-09 6:14
baranils12-Dec-09 6:14 
AnswerRe: Schedulle a task for some days of the week Pin
Abhinav S12-Dec-09 6:20
Abhinav S12-Dec-09 6:20 
AnswerRe: Schedulle a task for some days of the week Pin
Luc Pattyn12-Dec-09 6:22
sitebuilderLuc Pattyn12-Dec-09 6:22 
GeneralRe: Schedulle a task for some days of the week Pin
baranils12-Dec-09 6:35
baranils12-Dec-09 6:35 
GeneralRe: Schedulle a task for some days of the week Pin
baranils12-Dec-09 6:56
baranils12-Dec-09 6:56 
GeneralRe: Schedulle a task for some days of the week Pin
Luc Pattyn12-Dec-09 7:21
sitebuilderLuc Pattyn12-Dec-09 7:21 
GeneralRe: Schedulle a task for some days of the week Pin
baranils12-Dec-09 7:38
baranils12-Dec-09 7:38 
GeneralRe: Schedulle a task for some days of the week Pin
PIEBALDconsult12-Dec-09 8:55
mvePIEBALDconsult12-Dec-09 8:55 
GeneralRe: Schedulle a task for some days of the week Pin
baranils12-Dec-09 9:24
baranils12-Dec-09 9:24 
GeneralRe: Schedulle a task for some days of the week Pin
PIEBALDconsult12-Dec-09 9:35
mvePIEBALDconsult12-Dec-09 9:35 
AnswerRe: Schedulle a task for some days of the week Pin
PIEBALDconsult12-Dec-09 8:53
mvePIEBALDconsult12-Dec-09 8:53 
GeneralRe: Schedulle a task for some days of the week Pin
baranils12-Dec-09 12:02
baranils12-Dec-09 12:02 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.