W
William Stacey [MVP]
Man that seems like a very difficult and dangerous road to hoe. I would
pick one or the other and stick with it. If you pick async, you can still
turn that into a blocking call by wraping an reset even around it. I might
refactor your code to just use BeginReceives and figure a way to just use
that.
--
William Stacey [MVP]
| Hi,
| I am using sync and async operations on the same socket.
| generally I want the socket to wait on BeginReceive and to not block the
| object thread.
| but in some cases I want to stop the BeginReceive in the middle - Don't
| accept any data from it , and using regular Receive (I don't want the data
| will come to the BeginReceive byte buffer , instead of other buffer)
| then when I comlete some operaion , to return and call to the BeginReceive
| again.
| How can I do it ?
| I try to hold the AsynCallBack , and the IAsyncResult and call EndInvoke
but
| it make exceptions:
| Fail: The async result object is null or of an unexpected type. at
| System.Runtime.Remoting.Proxies.RealProxy.EndInvokeHelper(Message reqMsg,
| Boolean bProxyCase)
|
| at System.Runtime.Remoting.Proxies.RemotingProxy.Invoke(Object NotUsed,
| MessageData& msgData)
|
| at System.AsyncCallback.EndInvoke(IAsyncResult result)
|
| Thanks
|
|
pick one or the other and stick with it. If you pick async, you can still
turn that into a blocking call by wraping an reset even around it. I might
refactor your code to just use BeginReceives and figure a way to just use
that.
--
William Stacey [MVP]
| Hi,
| I am using sync and async operations on the same socket.
| generally I want the socket to wait on BeginReceive and to not block the
| object thread.
| but in some cases I want to stop the BeginReceive in the middle - Don't
| accept any data from it , and using regular Receive (I don't want the data
| will come to the BeginReceive byte buffer , instead of other buffer)
| then when I comlete some operaion , to return and call to the BeginReceive
| again.
| How can I do it ?
| I try to hold the AsynCallBack , and the IAsyncResult and call EndInvoke
but
| it make exceptions:
| Fail: The async result object is null or of an unexpected type. at
| System.Runtime.Remoting.Proxies.RealProxy.EndInvokeHelper(Message reqMsg,
| Boolean bProxyCase)
|
| at System.Runtime.Remoting.Proxies.RemotingProxy.Invoke(Object NotUsed,
| MessageData& msgData)
|
| at System.AsyncCallback.EndInvoke(IAsyncResult result)
|
| Thanks
|
|