Click here to Skip to main content
11,408,708 members (61,276 online)

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, embarrasing 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 PinmemberPIEBALDconsult17-Jan-13 18:17 
AnswerRe: I am in love <3 PinmemberAmgad Fahmi17-Jan-13 22:56 
GeneralRe: I am in love <3 Pinmemberdeepakaitr1234522-Jan-13 3:08 
GeneralReversing time, without a flux capacitor PinmemberGary R. Wheeler17-Jan-13 5:03 
GeneralRe: Reversing time, without a flux capacitor PinmemberLloyd Atkinson17-Jan-13 6:57 
GeneralRe: Reversing time, without a flux capacitor PinmemberGary R. Wheeler17-Jan-13 10:25 
GeneralRe: Reversing time, without a flux capacitor PinmemberLloyd Atkinson17-Jan-13 12:40 
GeneralRe: Reversing time, without a flux capacitor PinmemberBobJanova21-Jan-13 5:52 
GeneralRe: Reversing time, without a flux capacitor PinmemberBrisingr Aerowing17-Jan-13 15:25 
GeneralRe: Reversing time, without a flux capacitor PinmemberBobJanova21-Jan-13 5:56 
GeneralRe: Reversing time, without a flux capacitor Pinmemberenglebart23-Jan-13 4:35 
GeneralRe: Reversing time, without a flux capacitor PinmemberGary R. Wheeler23-Jan-13 12:45 
GeneralRe: Reversing time, without a flux capacitor PinmemberMember 793197823-Jan-13 6:44 
GeneralRe: Reversing time, without a flux capacitor PinmemberGary R. Wheeler23-Jan-13 12: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 PinmemberRafagaX23-Jan-13 7:21 
GeneralRe: Reversing time, without a flux capacitor PinmemberPaulo Zemek23-Jan-13 8:37 
GeneralRe: Reversing time, without a flux capacitor PinmemberJonathan C Dickinson3-Feb-13 23:47 
GeneralThe best refactoring I have ever seen Pinmembermatt_taws17-Jan-13 2:29 
GeneralRe: The best refactoring I have ever seen PinmemberSuper Lloyd17-Jan-13 3:42 
GeneralRe: The best refactoring I have ever seen PinmemberJonathan C Dickinson17-Jan-13 4:22 
GeneralRe: The best refactoring I have ever seen PinmemberPIEBALDconsult17-Jan-13 4:48 
GeneralRe: The best refactoring I have ever seen PinmemberRob Grainger1-Feb-13 4:17 
GeneralWhat was I thinking Pinmemberdjj5516-Jan-13 2:15 
GeneralRe: What was I thinking PinmemberDavid Goebet16-Jan-13 2:40 
GeneralRe: What was I thinking PinmemberMatt U.16-Jan-13 2:56 
GeneralRe: What was I thinking Pinmemberpeterchen16-Jan-13 4:24 
GeneralRe: What was I thinking PinmemberG James16-Jan-13 10:57 
JokeRe: What was I thinking PinadminChris Maunder16-Jan-13 19:02 
GeneralRe: What was I thinking Pinmember33deepak16-Jan-13 19:13 
GeneralRe: What was I thinking PinadminChris Maunder16-Jan-13 19:14 
GeneralRe: What was I thinking PinmemberJames Lonero19-Jan-13 12:08 
JokeRe: What was I thinking PinmemberAndrew Rissing17-Jan-13 6:48 
GeneralRe: What was I thinking PinadminChris Maunder17-Jan-13 10:43 
GeneralRe: What was I thinking PinmemberAndrew Rissing17-Jan-13 10:55 
JokeRe: What was I thinking PinmemberJecc23-Jan-13 0:56 
GeneralRe: What was I thinking PinmemberNagy Vilmos23-Jan-13 1:33 
GeneralRe: What was I thinking PinmemberJonathan C Dickinson16-Jan-13 22:21 
GeneralRe: What was I thinking PinmemberSentenryu16-Jan-13 23:23 
GeneralRe: What was I thinking PinmemberJonathan C Dickinson16-Jan-13 23:26 
GeneralRe: What was I thinking PinmemberRanjan.D17-Jan-13 12:32 
GeneralRe: What was I thinking PinmemberRob Grainger1-Feb-13 4:21 
GeneralRe: What was I thinking PinmemberTomz_KV17-Jan-13 3:58 
RantHappy new year... kind of... Pinmemberhoernchenmeister15-Jan-13 23:03 
GeneralRe: Happy new year... kind of... PinmemberPIEBALDconsult16-Jan-13 4:50 
GeneralRe: Happy new year... kind of... Pinmemberhoernchenmeister16-Jan-13 6:06 
GeneralRe: Happy new year... kind of... PinmemberMatthys Terblanche16-Jan-13 22:08 
GeneralRe: Happy new year... kind of... PinmemberGary Huck17-Jan-13 4:41 
GeneralRe: Happy new year... kind of... PinmvpDave Kreskowiak17-Jan-13 6:26 
GeneralRe: Happy new year... kind of... PinmemberJörgen Andersson17-Jan-13 10:04 
GeneralRe: Happy new year... kind of... Pinmemberpeterchen28-Jan-13 23:05 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.


Advertise | Privacy | Mobile
Web02 | 2.8.150414.5 | Last Updated 24 Apr 2015
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid