Discussion:
Newbie:Calling Socket.BeginSend inside SendCallback
(too old to reply)
Navin Mishra
2007-04-25 17:36:25 UTC
Permalink
Hi,

I want to send data asynchronously to a connected end point using
Socket.BeginSend but need to dispatch data in order from a queue. So, would
it be a good idea to call BeginSend again inside SendCallback to initiate
another asynchronous send if there is data remaining to be send ? Or is it
not good idea after all and has potential to use all threads from IO thread
pool or cause a "stack dive" ?

Thanks in advance and regards

Navin
Arkady Frenkel
2007-04-26 17:12:13 UTC
Permalink
That not good idea, because SendCallback called on the different thread, to
all main thread ( on which BeginSend called ) to continue , so if you call
inside another
BeginSend that cause another thread to start so you'll have a lot of thread
each one try to send some data that will have no guarantee that data will be
send in needed order
Arkady
Post by Navin Mishra
Hi,
I want to send data asynchronously to a connected end point using
Socket.BeginSend but need to dispatch data in order from a queue. So,
would it be a good idea to call BeginSend again inside SendCallback to
initiate another asynchronous send if there is data remaining to be send ?
Or is it not good idea after all and has potential to use all threads from
IO thread pool or cause a "stack dive" ?
Thanks in advance and regards
Navin
Loading...