Click here to Skip to main content
11,480,701 members (48,602 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 Pin
PIEBALDconsult17-Jan-13 13:44
memberPIEBALDconsult17-Jan-13 13:44 
GeneralRe: I am in love <3 Pin
lewax0017-Jan-13 14:06
memberlewax0017-Jan-13 14:06 
GeneralRe: I am in love <3 Pin
PIEBALDconsult17-Jan-13 14:15
memberPIEBALDconsult17-Jan-13 14:15 
GeneralRe: I am in love <3 Pin
Brisingr Aerowing17-Jan-13 15:15
memberBrisingr Aerowing17-Jan-13 15:15 
GeneralRe: I am in love <3 Pin
lewax0017-Jan-13 16:15
memberlewax0017-Jan-13 16:15 
GeneralRe: I am in love <3 Pin
PIEBALDconsult17-Jan-13 16:57
memberPIEBALDconsult17-Jan-13 16:57 
GeneralRe: I am in love <3 Pin
Amgad Fahmi17-Jan-13 22:54
memberAmgad Fahmi17-Jan-13 22:54 
GeneralRe: I am in love <3 Pin
Chris Quinn17-Jan-13 22:15
memberChris Quinn17-Jan-13 22:15 
GeneralRe: I am in love <3 Pin
PIEBALDconsult17-Jan-13 13:43
memberPIEBALDconsult17-Jan-13 13:43 
QuestionRe: I am in love <3 Pin
Guirec Le Bars17-Jan-13 15:15
memberGuirec Le Bars17-Jan-13 15:15 
GeneralRe: I am in love <3 Pin
PIEBALDconsult17-Jan-13 18:17
memberPIEBALDconsult17-Jan-13 18:17 
AnswerRe: I am in love <3 Pin
Amgad Fahmi17-Jan-13 22:56
memberAmgad Fahmi17-Jan-13 22:56 
GeneralRe: I am in love <3 Pin
deepakaitr1234522-Jan-13 3:08
memberdeepakaitr1234522-Jan-13 3:08 
GeneralReversing time, without a flux capacitor Pin
Gary R. Wheeler17-Jan-13 5:03
memberGary R. Wheeler17-Jan-13 5:03 
Our C# application uses TCP/IP sockets for interprocess communication. I use the Socket class asynchronous methods to process received messages, something like this:
// start initial receive operation
s.BeginReceive(...,OnReceive);
...
void OnReceive(...)
{
   lock(...)
   {
       // fetch incoming message
       ...
       // start next receive operation
       s.BeginReceive(...,OnReceive)
   }
   // process received message outside of lock to avoid holding it for a long time
   ...
}
I discovered that the OnReceive was being called recursively under heavy traffic conditions, resulting in messages being processed in reverse order for brief periods D'Oh! | :doh: Sigh | :sigh: . The solution went something like this:
// start initial receive operation
s.BeginReceive(...,OnReceive);
...
void OnReceive(...)
{
   lock(...)
   {
       // fetch incoming message
       ...
   }
   // process received message outside of lock to avoid holding it for a long time
   ...
   // start next receive operation
   s.BeginReceive(...,OnReceive)
}
The time-reversing version has been in the product since 2008, and I only discovered it a week ago. One petard-wedgie, coming up.
Software Zen: delete this;

GeneralRe: Reversing time, without a flux capacitor Pin
Lloyd Atkinson17-Jan-13 6:57
memberLloyd Atkinson17-Jan-13 6:57 
GeneralRe: Reversing time, without a flux capacitor Pin
Gary R. Wheeler17-Jan-13 10:25
memberGary R. Wheeler17-Jan-13 10:25 
GeneralRe: Reversing time, without a flux capacitor Pin
Lloyd Atkinson17-Jan-13 12:40
memberLloyd Atkinson17-Jan-13 12:40 
GeneralRe: Reversing time, without a flux capacitor Pin
BobJanova21-Jan-13 5:52
memberBobJanova21-Jan-13 5:52 
GeneralRe: Reversing time, without a flux capacitor Pin
Brisingr Aerowing17-Jan-13 15:25
memberBrisingr Aerowing17-Jan-13 15:25 
GeneralRe: Reversing time, without a flux capacitor Pin
BobJanova21-Jan-13 5:56
memberBobJanova21-Jan-13 5:56 
GeneralRe: Reversing time, without a flux capacitor Pin
englebart23-Jan-13 4:35
memberenglebart23-Jan-13 4:35 
GeneralRe: Reversing time, without a flux capacitor Pin
Gary R. Wheeler23-Jan-13 12:45
memberGary R. Wheeler23-Jan-13 12:45 
GeneralRe: Reversing time, without a flux capacitor Pin
Member 793197823-Jan-13 6:44
memberMember 793197823-Jan-13 6:44 
GeneralRe: Reversing time, without a flux capacitor Pin
Gary R. Wheeler23-Jan-13 12:58
memberGary R. Wheeler23-Jan-13 12:58 
JokeRe: Reversing time, without a flux capacitor Pin
RafagaX23-Jan-13 7:21
memberRafagaX23-Jan-13 7:21 
GeneralRe: Reversing time, without a flux capacitor Pin
Paulo Zemek23-Jan-13 8:37
memberPaulo Zemek23-Jan-13 8:37 
GeneralRe: Reversing time, without a flux capacitor Pin
Jonathan C Dickinson3-Feb-13 23:47
memberJonathan C Dickinson3-Feb-13 23:47 
GeneralThe best refactoring I have ever seen Pin
matt_taws17-Jan-13 2:29
membermatt_taws17-Jan-13 2:29 
GeneralRe: The best refactoring I have ever seen Pin
Super Lloyd17-Jan-13 3:42
memberSuper Lloyd17-Jan-13 3:42 
GeneralRe: The best refactoring I have ever seen Pin
Jonathan C Dickinson17-Jan-13 4:22
memberJonathan C Dickinson17-Jan-13 4:22 
GeneralRe: The best refactoring I have ever seen Pin
PIEBALDconsult17-Jan-13 4:48
memberPIEBALDconsult17-Jan-13 4:48 
GeneralRe: The best refactoring I have ever seen Pin
Rob Grainger1-Feb-13 4:17
memberRob Grainger1-Feb-13 4:17 
GeneralWhat was I thinking Pin
djj5516-Jan-13 2:15
memberdjj5516-Jan-13 2:15 
GeneralRe: What was I thinking Pin
David Goebet16-Jan-13 2:40
memberDavid Goebet16-Jan-13 2:40 
GeneralRe: What was I thinking Pin
Matt U.16-Jan-13 2:56
memberMatt U.16-Jan-13 2:56 
GeneralRe: What was I thinking Pin
peterchen16-Jan-13 4:24
memberpeterchen16-Jan-13 4:24 
GeneralRe: What was I thinking Pin
G James16-Jan-13 10:57
memberG James16-Jan-13 10:57 
JokeRe: What was I thinking Pin
Chris Maunder16-Jan-13 19:02
adminChris Maunder16-Jan-13 19:02 
GeneralRe: What was I thinking Pin
33deepak16-Jan-13 19:13
member33deepak16-Jan-13 19:13 
GeneralRe: What was I thinking Pin
Chris Maunder16-Jan-13 19:14
adminChris Maunder16-Jan-13 19:14 
GeneralRe: What was I thinking Pin
James Lonero19-Jan-13 12:08
memberJames Lonero19-Jan-13 12:08 
JokeRe: What was I thinking Pin
Andrew Rissing17-Jan-13 6:48
memberAndrew Rissing17-Jan-13 6:48 
GeneralRe: What was I thinking Pin
Chris Maunder17-Jan-13 10:43
adminChris Maunder17-Jan-13 10:43 
GeneralRe: What was I thinking Pin
Andrew Rissing17-Jan-13 10:55
memberAndrew Rissing17-Jan-13 10:55 
JokeRe: What was I thinking Pin
Jecc23-Jan-13 0:56
memberJecc23-Jan-13 0:56 
GeneralRe: What was I thinking Pin
Nagy Vilmos23-Jan-13 1:33
memberNagy Vilmos23-Jan-13 1:33 
GeneralRe: What was I thinking Pin
Jonathan C Dickinson16-Jan-13 22:21
memberJonathan C Dickinson16-Jan-13 22:21 
GeneralRe: What was I thinking Pin
Sentenryu16-Jan-13 23:23
memberSentenryu16-Jan-13 23:23 
GeneralRe: What was I thinking Pin
Jonathan C Dickinson16-Jan-13 23:26
memberJonathan C Dickinson16-Jan-13 23:26 
GeneralRe: What was I thinking Pin
Ranjan.D17-Jan-13 12:32
memberRanjan.D17-Jan-13 12:32 

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
Web01 | 2.8.150520.1 | Last Updated 24 May 2015
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid