Click here to Skip to main content
15,901,426 members
Home / Discussions / C#
   

C#

 
GeneralRe: Very Simple HTML Parser C# Pin
justme8921-Jul-10 14:27
justme8921-Jul-10 14:27 
GeneralRe: Very Simple HTML Parser C# Pin
Ravi Bhavnani21-Jul-10 18:34
professionalRavi Bhavnani21-Jul-10 18:34 
GeneralRe: Very Simple HTML Parser C# Pin
jschell22-Jul-10 8:27
jschell22-Jul-10 8:27 
AnswerRe: Very Simple HTML Parser C# Pin
V.21-Jul-10 20:59
professionalV.21-Jul-10 20:59 
GeneralRe: Very Simple HTML Parser C# Pin
Luc Pattyn21-Jul-10 21:05
sitebuilderLuc Pattyn21-Jul-10 21:05 
GeneralRe: Very Simple HTML Parser C# Pin
V.21-Jul-10 22:53
professionalV.21-Jul-10 22:53 
QuestionSeriously silly sockets - please assist Pin
GrenMeera21-Jul-10 9:56
GrenMeera21-Jul-10 9:56 
AnswerRe: Seriously silly sockets - please assist Pin
Jimmanuel21-Jul-10 10:34
Jimmanuel21-Jul-10 10:34 
When you close a Socket I believe any pending asynchronous callbacks are fired to terminate said callbacks. It's by design so it's something you need to handle in your code. When you call EndReceive (or EndAnything for that matter) it can can throw any number of exceptions to indicate failures from the pending operation so those methods should always be wrapped in a try {} catch (stuff) {} block. Basically, anything the synchronous versions of the methods can throw, the asynchronous ones can throw too with some extra ones for good measure. Catching those exceptions is one way that your code could know that it should exit from the callback without initiating another async method call. Another way would be to check a flag in the receive callback that is set in CloseConnections to indicate that work is done.

It also looks like you might be being bit by a lack of thread safety. Async callbacks are executed on Threadpool threads so it's a good bet that CloseConnections and the receive callback are racing to use the socket at the same time. A simple lock(_recvState) { /* use the shared resources here */ } around places where the shared resource are used will be sufficient to protect them.
Badger | [badger,badger,badger,badger...]

GeneralRe: Seriously silly sockets - please assist Pin
GrenMeera22-Jul-10 5:11
GrenMeera22-Jul-10 5:11 
GeneralRe: Seriously silly sockets - please assist Pin
Jimmanuel22-Jul-10 7:26
Jimmanuel22-Jul-10 7:26 
AnswerRe: Seriously silly sockets - please assist Pin
LimitedAtonement21-Jul-10 10:42
LimitedAtonement21-Jul-10 10:42 
GeneralRe: Seriously silly sockets - please assist Pin
GrenMeera22-Jul-10 5:18
GrenMeera22-Jul-10 5:18 
GeneralRe: Seriously silly sockets - please assist Pin
jschell22-Jul-10 8:38
jschell22-Jul-10 8:38 
QuestionRe: Seriously silly sockets - please assist Pin
Jimmanuel22-Jul-10 9:20
Jimmanuel22-Jul-10 9:20 
QuestionOnly in Release config, SetWindowsHookEx throws error 80004005 Pin
LimitedAtonement21-Jul-10 9:36
LimitedAtonement21-Jul-10 9:36 
AnswerRe: Only in Release config, SetWindowsHookEx throws error 80004005 Pin
Dave Kreskowiak21-Jul-10 10:22
mveDave Kreskowiak21-Jul-10 10:22 
Question? : Operator Pin
I Believe In GOD21-Jul-10 7:00
I Believe In GOD21-Jul-10 7:00 
AnswerRe: ? : Operator PinPopular
harold aptroot21-Jul-10 7:02
harold aptroot21-Jul-10 7:02 
GeneralRe: ? : Operator Pin
I Believe In GOD21-Jul-10 7:06
I Believe In GOD21-Jul-10 7:06 
GeneralRe: ? : Operator Pin
harold aptroot21-Jul-10 7:13
harold aptroot21-Jul-10 7:13 
GeneralRe: ? : Operator Pin
I Believe In GOD21-Jul-10 7:12
I Believe In GOD21-Jul-10 7:12 
AnswerRe: ? : Operator Pin
Luc Pattyn21-Jul-10 7:02
sitebuilderLuc Pattyn21-Jul-10 7:02 
GeneralRe: ? : Operator Pin
I Believe In GOD21-Jul-10 7:10
I Believe In GOD21-Jul-10 7:10 
GeneralRe: ? : Operator Pin
Roger Wright21-Jul-10 7:54
professionalRoger Wright21-Jul-10 7:54 
GeneralRe: ? : Operator Pin
Luc Pattyn21-Jul-10 8:05
sitebuilderLuc Pattyn21-Jul-10 8:05 

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.