-
May 9th, 2013, 08:25 AM
#1
Thread Starter
New Member
Endreceive when Formclosing is intiated
Hi,
I am programming a server-client socket software. On client side, when I click on the close window at the right upper side [X] Formclosing is initiated. I want to send to the server some information about disconnecting socket. My problem is that the client is in receiving state and I need to stop receiving state by calling socket.endreceive. I can't do that in Formclosing cause It need IASyncResult object that is not accessible.
Is there a way to achieve that?
many thanks.
Patrice
-
Jun 4th, 2013, 11:01 AM
#2
Addicted Member
Re: Endreceive when Formclosing is intiated
I feel/think you are misunderstanding the purpose of socket.endreceive.
see this link
http://msdn.microsoft.com/en-us/library/w7wtt64b.aspx
Try closing the socket in the Formclosing method. This will cause socket.endreceive to throw an ObjectDisposedException exception.
Handle this exception in a try catch block.
Last edited by 2ndmessiah; Jun 4th, 2013 at 11:06 AM.
Reason: Pitiful bad spelling and grammar.
Think.... Question.....
-
Jun 7th, 2013, 07:52 AM
#3
Thread Starter
New Member
Re: Endreceive when Formclosing is intiated
Originally Posted by 2ndmessiah
I feel/think you are misunderstanding the purpose of socket.endreceive.
see this link
http://msdn.microsoft.com/en-us/library/w7wtt64b.aspx
Try closing the socket in the Formclosing method. This will cause socket.endreceive to throw an ObjectDisposedException exception.
Handle this exception in a try catch block.
Thank you for the answer. I know what endreceive does. What I want to do is currently using endreceive to stop reading state and sending a message to the server side. But on FormClosing, I don't see how I can call endreceive without IaSync object.
do you have any idea on what I can do?
many thanks.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|