Click here to Skip to main content
15,908,661 members

The Weird and The Wonderful

   

The Weird and The Wonderful forum is a place to post Coding Horrors, Worst Practices, and the occasional flash of brilliance.

We all come across code that simply boggles the mind. Lazy kludges, embarrassing mistakes, horrid workarounds and developers just not quite getting it. And then somedays we come across - or write - the truly sublime.

Post your Best, your worst, and your most interesting. But please - no programming questions . This forum is purely for amusement and discussions on code snippets. All actual programming questions will be removed.

 
GeneralRe: I am in love <3 Pin
lewax0017-Jan-13 15:15
lewax0017-Jan-13 15:15 
GeneralRe: I am in love <3 Pin
PIEBALDconsult17-Jan-13 15:57
mvePIEBALDconsult17-Jan-13 15:57 
GeneralRe: I am in love <3 Pin
Amgad Fahmi17-Jan-13 21:54
Amgad Fahmi17-Jan-13 21:54 
GeneralRe: I am in love <3 Pin
Chris Quinn17-Jan-13 21:15
Chris Quinn17-Jan-13 21:15 
GeneralRe: I am in love <3 Pin
PIEBALDconsult17-Jan-13 12:43
mvePIEBALDconsult17-Jan-13 12:43 
QuestionRe: I am in love <3 Pin
Guirec17-Jan-13 14:15
professionalGuirec17-Jan-13 14:15 
GeneralRe: I am in love <3 Pin
PIEBALDconsult17-Jan-13 17:17
mvePIEBALDconsult17-Jan-13 17:17 
AnswerRe: I am in love <3 Pin
Amgad Fahmi17-Jan-13 21:56
Amgad Fahmi17-Jan-13 21:56 
GeneralRe: I am in love <3 Pin
deepakaitr1234522-Jan-13 2:08
deepakaitr1234522-Jan-13 2:08 
GeneralReversing time, without a flux capacitor Pin
Gary R. Wheeler17-Jan-13 4:03
Gary R. Wheeler17-Jan-13 4:03 
GeneralRe: Reversing time, without a flux capacitor Pin
LloydA11117-Jan-13 5:57
LloydA11117-Jan-13 5:57 
GeneralRe: Reversing time, without a flux capacitor Pin
Gary R. Wheeler17-Jan-13 9:25
Gary R. Wheeler17-Jan-13 9:25 
GeneralRe: Reversing time, without a flux capacitor Pin
LloydA11117-Jan-13 11:40
LloydA11117-Jan-13 11:40 
GeneralRe: Reversing time, without a flux capacitor Pin
BobJanova21-Jan-13 4:52
BobJanova21-Jan-13 4:52 
GeneralRe: Reversing time, without a flux capacitor Pin
Brisingr Aerowing17-Jan-13 14:25
professionalBrisingr Aerowing17-Jan-13 14:25 
GeneralRe: Reversing time, without a flux capacitor Pin
BobJanova21-Jan-13 4:56
BobJanova21-Jan-13 4:56 
GeneralRe: Reversing time, without a flux capacitor Pin
englebart23-Jan-13 3:35
professionalenglebart23-Jan-13 3:35 
GeneralRe: Reversing time, without a flux capacitor Pin
Gary R. Wheeler23-Jan-13 11:45
Gary R. Wheeler23-Jan-13 11:45 
GeneralRe: Reversing time, without a flux capacitor Pin
Member 793197823-Jan-13 5:44
professionalMember 793197823-Jan-13 5:44 
GeneralRe: Reversing time, without a flux capacitor Pin
Gary R. Wheeler23-Jan-13 11:58
Gary R. Wheeler23-Jan-13 11:58 
Member 7931978 wrote:
This only works if you have only two calls to OnReceive() happening at once, no
The key here is the BeginReceive call, which tells the .NET socket support to call the OnReceive delegate asynchronously on a thread pool thread when a message is received. In my initial code that has the bug, I was issuing the second BeginReceive call to start receipt of the next message before I'd finished processing the current message. Under high load conditions, this could cause the OnReceive handler to be called recursively. The actual message handling would then be processed in reverse order as the stack unwound.
Member 7931978 wrote:
what guarantee do you have that the "correct" thread will be the next one to acquire the lock?
The lock in this case was protecting the socket connection, so there is no 'correct' thread per se. The .NET socket support can call the asynchronous delegate on any thread it has available. The lock is essentially a critical section.
Software Zen: delete this;

JokeRe: Reversing time, without a flux capacitor Pin
RafagaX23-Jan-13 6:21
professionalRafagaX23-Jan-13 6:21 
GeneralRe: Reversing time, without a flux capacitor Pin
Paulo Zemek23-Jan-13 7:37
Paulo Zemek23-Jan-13 7:37 
GeneralRe: Reversing time, without a flux capacitor Pin
Jonathan C Dickinson3-Feb-13 22:47
Jonathan C Dickinson3-Feb-13 22:47 
GeneralThe best refactoring I have ever seen Pin
matt_taws17-Jan-13 1:29
matt_taws17-Jan-13 1:29 
GeneralRe: The best refactoring I have ever seen Pin
Super Lloyd17-Jan-13 2:42
Super Lloyd17-Jan-13 2:42 

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.