Mithrinder
asked on
Async and Sync HttpWebRequests
Hello Experts,
I am hoping to get a little better understanding about how these requests affect each other.
I have two routines I am using to gather data from the same source. They are getting exactly the same type of data. The async request gets a larger amount of data, it does this every 15 secs. The sync request gets a much smaller set of the same data typically 1/250 the size, it does this as quickly as it is able and averages about 1 sec when there is no async request pending.
When the async request is receiving its data but is not finished yet I notice that the sync request time increases to 3 secs. Here is an example of the time stamps
req sync 1
rec sync 2
req sync 2
rec sync 3
rec async 3
ack async request 3
req sync 3
rec sync 6
chk async 6 not done
req sync 6
rec sync 9
chk async 9 done
rec async 10
req sync 10
rec sync 11
req sync 11
rec sync 12
...
I am trying to understand what is happening when both streams are being received at the same time. Is the delay on the sync steam caused because they must be received serially? Ie a chunk comes in from the async then some comes in from the sync, then more from the async? The sync request waits as long as is necessary to receive all its packets which are interspersed with the async packets?
Thanks for you comments!
I am hoping to get a little better understanding about how these requests affect each other.
I have two routines I am using to gather data from the same source. They are getting exactly the same type of data. The async request gets a larger amount of data, it does this every 15 secs. The sync request gets a much smaller set of the same data typically 1/250 the size, it does this as quickly as it is able and averages about 1 sec when there is no async request pending.
When the async request is receiving its data but is not finished yet I notice that the sync request time increases to 3 secs. Here is an example of the time stamps
req sync 1
rec sync 2
req sync 2
rec sync 3
rec async 3
ack async request 3
req sync 3
rec sync 6
chk async 6 not done
req sync 6
rec sync 9
chk async 9 done
rec async 10
req sync 10
rec sync 11
req sync 11
rec sync 12
...
I am trying to understand what is happening when both streams are being received at the same time. Is the delay on the sync steam caused because they must be received serially? Ie a chunk comes in from the async then some comes in from the sync, then more from the async? The sync request waits as long as is necessary to receive all its packets which are interspersed with the async packets?
Thanks for you comments!
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Anyone? Comments on the mechanics of how the data is received?
There is no way to block your async request while you process a sync request.
ASKER
I can have time stamps like this for one async request or like this for the same size data
req async 1 req async 1
ack async request 1 ack async request 1
req sync 1 req sync 1
rec sync 4 rec sync 4
chk async 4 not done chk async 4 not done
req sync 4 req sync 4
rec sync 6 rec sync 5
chk async 6 not done hk async 5 done
req sync 6 rec async 5
rec sync 7
chk async 7 done
rec async 7
gregoryyoung - You are correct each as it's own stream and unique connection.
What I am trying to understand is how is the data actually received to the steam, are they just individual packets? Each is packet is received, buffered, and built into a file as they are received? This would explain the delay on the sync request when processing the async request as async packets are also in the datasteam so it takes longer to receive all the sync packets? ie the data could look like async packet, async packet, sync packet, async packet, async packet, async packet, sync packet, sync packet, async packet, sync packet.....
What I desire is the following:
req async 1
ack async1
req sync 1
rec sync 2
chk async 2 not done
req sync 2
rec sync 3
chk async 3 not done
req sync 3
rec sync 4
chk async 4 not done
req sync 4
rec sync 5
chk async 5 not done
req sync 5
rec sync 6
chk async 6 done
rec async 6
I dont think this would be possible for the async right? Once requested the async stream will continue to send packets until complete right? Is there a way to do the following?
req async 1
ack async1
get async data for 1 sec
hold async data
req sync 1
rec sync 2
resume getting async data for 1 sec
...repeat until done with async request