Don't read this, you will regret it if you do... Honestly.



  • 
            public Logger()
            {
                threadDatabase = new Thread(new ThreadStart(DatabaseThread));
                threadDatabase.Start();
            }
    
            private void DatabaseThread()
            {
                while (true)
                {
                    IsDatabaseConnection = true;
                    Thread.Sleep(3000);
                }
            }
    
            /*
            private bool CheckDatabaseConnection()
            {
                
                try
                {
                    using (Entities entities = new Entities(Config.Instance.ConnectionString))
                    {
    
                        var q = from a in entities.models select a.Idtr;
                        int c = q.Count();
                    }
                }
                catch
               {
                    return false;
                }
    
                return true;
            }*/ 
    
    

    What is the policy on swearing around here?



  • There is no curse in Elvish, Entish, or the tongues of Men for this WTFery.

    Seriously. Just Ewww to the Ewwwth power. Divided by zero.



  • Just as a general aside, it sure would be nice if people took 2 minutes to explain why their snippet is a WTF. Not everyone programs in the language you use.

    Interesting approach to connection testing. How often is it actually called?

    I also really like the poorly named IsDatabaseConnection boolean. Is it supposed to mean "connected" or is it doing some sort of poor man's type checking? And is the capital at the beginning because it's an internal property, or because the developer just can't follow variable naming conventions?

    So many questions!



  • ...and why does a logger need to have an asynchronous database thread?



  • @Soviut said:

    And is the capital at the beginning because it's an internal property, or because the developer just can't follow variable naming conventions?
    I don't know what you mean with "internal" property (unless it means "a property defined with the internal keyword, giving it assembly scope", which would not make a difference). It's only about variable vs. property. I assume that it is a property (and given the kind of mentality displayed in the code given by the OP, I wouldn't be surprised if it is one that is heavily stacked with side effects in its setter - like parsing an XML config file, creating a database connection, calculating the flight path of the next mars probe etc.) which would make the capital appropriate according to the common C# naming convention (which I also assume is the language the code is written in).



  • @TheRider said:

    ...and why does a logger need to have an asynchronous database thread?

    Because with this method, the database is always connected! look, it's written in the... well, where is it logged?



  • Well, at least is thread safe.


  • Discourse touched me in a no-no place

    @Soviut said:

    Interesting approach to connection testing. How often is it actually called?
    CheckDatabaseConnection() would appear to be called zero times, since it's actually commented out.



  • @PJH said:

    @Soviut said:
    Interesting approach to connection testing. How often is it actually called?
    CheckDatabaseConnection() would appear to be called zero times, since it's actually commented out.

    Ah, I totally missed that. I was distracted by the highlighting.



  • Using a sleep in a thread.... some people just don't get it.



  • @Weps said:

    Using a sleep in a thread.... some people just don't get it.

    Where else would you use one?



  • @Soviut said:

    @PJH said:
    @Soviut said:
    Interesting approach to connection testing. How often is it actually called?
    CheckDatabaseConnection() would appear to be called zero times, since it's actually commented out.

    Ah, I totally missed that. I was distracted by the highlighting.

    Well that's the opposite of what it's supposed to do!

    The entire code sample looks like somebody wrote a stub implementation of something and never got around to coming back and finishing it off.




  •  A hypnotists stage act? Probably not as hard to follow as that code example..



  • @jverd said:

    @Weps said:
    Using a sleep in a thread.... some people just don't get it.

    Where else would you use one?

    Wait! I'll come back to you with a smart reply!



  • @Weps said:

    Using a sleep in a thread.... some people just don't get it.

    Everything is in a thread.


  • @Weps said:

    @jverd said:
    @Weps said:
    Using a sleep in a thread.... some people just don't get it.

    Where else would you use one?
    Wait! I'll come back to you with a smart reply!

    K, cool. While you're working on that reply, we'll keep on discussing other things.



  • @Xyro said:

    @Weps said:
    @jverd said:
    @Weps said:
    Using a sleep in a thread.... some people just don't get it.
    Where else would you use one?
    Wait! I'll come back to you with a smart reply!
    K, cool. While you're working on that reply, we'll keep on discussing other things.

     No no,I said "wait". I can't work on a reply while you keep on discussing other things.



  • @Weps said:

    @Xyro said:
    @Weps said:
    @jverd said:
    @Weps said:
    Using a sleep in a thread.... some people just don't get it.

    Where else would you use one?
    Wait! I'll come back to you with a smart reply!

    K, cool. While you're working on that reply, we'll keep on discussing other things.
    No no,I said "wait". I can't work on a reply while you keep on discussing other things.

    Why not? Just take an immutable snapshot of the posts and process your reply from that copy. When you're finished, you can post your reply and then read up on what you missed.

    This is a contention-free forum. ... modulo CS quirks.



  • I was doing exactly that, but I went in between for a rest, and now, I can start over. Just wait.



  • @Weps said:

    I was doing exactly that, but I went in between for a rest, and now, I can start over. Just wait.

    Wtf dude! Focus! Stop reloading the page! Take a screenshot if you have to!

    Compose your reply, post it, then check back for updates. Meanwhile, the rest of us are doing the same while napping in between updates so we don't crash CS by constantly hitting F5.



  • @Xyro said:

    @Weps said:
    I was doing exactly that, but I went in between for a rest, and now, I can start over. Just wait.
    Wtf dude! Focus! Stop reloading the page! Take a screenshot if you have to!

    Compose your reply, post it, then check back for updates. Meanwhile, the rest of us are doing the same while napping in between updates so we don't crash CS by sometimes hitting a random key or looking it the wrong way or being Wenesday or any of the other assorted reason that makes CS crap itself.

    FTFY



  • @Xyro said:

    @Weps said:
    @Xyro said:
    @Weps said:
    @jverd said:
    @Weps said:
    Using a sleep in a thread.... some people just don't get it.
    Where else would you use one?
    Wait! I'll come back to you with a smart reply!
    K, cool. While you're working on that reply, we'll keep on discussing other things.
    No no,I said "wait". I can't work on a reply while you keep on discussing other things.
    Why not? Just take an immutable snapshot of the posts and process your reply from that copy. When you're finished, you can post your reply and then read up on what you missed.

    All snapshots are mutable, thanks to Photoshop.

    Except for ones that have been printed out and put on a wooden table, of course.




  • @frits said:

    @Weps said:

    Using a sleep in a thread.... some people just don't get it.

    Everything is in a thread.

    Ummm.....NO.

    (think kernel / hardware interrupt service routines, these often operate well below any level that has a concept of a thread.)



  • @Soviut said:

    Just as a general aside, it sure would be nice if people took 2 minutes to explain why their snippet is a WTF. Not everyone programs in the language you use.

    Sorry, I assumed the WTF would be able to transcend language barriers. I think the other comments have cleared most of it up for me though :)

    @Anonymouse said:

    I assume that it is a property (and given the kind of mentality displayed in the code given by the OP, I wouldn't be surprised if it is one that is heavily stacked with side effects in its setter - like parsing an XML config file, creating a database connection, calculating the flight path of the next mars probe etc.)

    Believe it or not it is just a regular, completely public (getter and setter) property that is never used for anything to do with logging. The setters of most properties on the config class do however re-generate the entire XML config file.

    @jverd said:

    @Weps said:
    Using a sleep in a thread.... some people just don't get it.

    Where else would you use one?

    I normally try to use it in bed. Last night it did throw a CantSleepException with an inner exception of WTFOverflowException though (trust me, there is more than just the OP), can anyone help me debug this one?.



  • @TheCPUWizard said:

    @frits said:

    @Weps said:

    Using a sleep in a thread.... some people just don't get it.

    Everything is in a thread.

    Ummm.....NO.

    (think kernel / hardware interrupt service routines, these often operate well below any level that has a concept of a thread.)

    OK, so that's where you use sleep?  I can't remember the last time I wrote an ISR in C#.  BTW, how the heck do I spawn my secondary interrupt handler without access to threads?



  • @TheCPUWizard said:

    @frits said:
    @Weps said:
    Using a sleep in a thread.... some people just don't get it.
    Everything is in a thread.
    Ummm.....NO.(think kernel / hardware interrupt service routines, these often operate well below any level that has a concept of a thread.)

    TheCPUWizard, I've noticed that you are very good at working at the wrong level of abstraction...



  • @ubersoldat said:

    Well, at least is thread safe.
     

    No it's not. What if another thread is setting IsDatabaseConnection to false at the same time?  It needs a lock.



  • @Xyro said:

    TheCPUWizard, I've noticed that you are very good at working at the wrong level of abstraction...

    Typical pedantic dickery.

    Combined with a healthy dose of, "oh I'm so much smarter than you because you said something that, if taken literally, is wrong, watch me prove how smart I am by correcting it!" The fact that the statement is practically correct doesn't matter. (Actually, I'm pretty sure the assholes who do stuff like this don't even know what the word "practically" means.)



  • @blakeyrat said:

    @Xyro said:
    TheCPUWizard, I've noticed that you are very good at working at the wrong level of abstraction...
    Typical pedantic dickery.

    Combined with a healthy dose of, "oh I'm so much smarter than you because you said something that, if taken literally, is wrong, watch me prove how smart I am by correcting it!" The fact that the statement is practically correct doesn't matter. (Actually, I'm pretty sure the assholes who do stuff like this don't even know what the word "practically" means.)

    Partly correct...  I think the other part of it is that he has no knowledge of .Net or C# and is trying to push this thread into his comfort zone (which is probably low level programming).

    Remember, if you can't beat 'em, change the subject completely.



  • @C-Octothorpe said:

    @blakeyrat said:

    @Xyro said:
    TheCPUWizard, I've noticed that you are very good at working at the wrong level of abstraction...
    Typical pedantic dickery.

    Combined with a healthy dose of, "oh I'm so much smarter than you because you said something that, if taken literally, is wrong, watch me prove how smart I am by correcting it!" The fact that the statement is practically correct doesn't matter. (Actually, I'm pretty sure the assholes who do stuff like this don't even know what the word "practically" means.)

    Partly correct...  I think the other part of it is that he has no knowledge of .Net or C# and is trying to push this thread into his comfort zone (which is probably low level programming).

    Remember, if you can't beat 'em, change the subject completely.

    The real annoying part is no matter how many times people point out how fucking irritating that behavior is (and it's been done many times before), he still does it.



  • @blakeyrat said:

    @Xyro said:
    TheCPUWizard, I've noticed that you are very good at working at the wrong level of abstraction...

    Typical pedantic dickery.

    Combined with a healthy dose of, "oh I'm so much smarter than you because you said something that, if taken literally, is wrong, watch me prove how smart I am by correcting it!" The fact that the statement is practically correct doesn't matter.

    You're quoting Xyro, but your comments apply more properly to TheCPUWizard's post that Xyro was commenting on.

    Was that a quotypo on your part, or are you just truly that clueless?



  • @blakeyrat said:

    Typical pedantic dickery.

    Isn't the term "pedantic dickweedery"?


  • @jverd said:

    @blakeyrat said:
    @Xyro said:
    TheCPUWizard, I've noticed that you are very good at working at the wrong level of abstraction...
    Typical pedantic dickery.

    Combined with a healthy dose of, "oh I'm so much smarter than you because you said something that, if taken literally, is wrong, watch me prove how smart I am by correcting it!" The fact that the statement is practically correct doesn't matter.

    You're quoting Xyro, but your comments apply more properly to TheCPUWizard's post that Xyro was commenting on. Was that a quotypo on your part, or are you just truly that clueless?
    I believe he was agreeing with Xyro.

    @jverd said:

    or are you just truly that clueless?

     BTW, what the hell was the point of chucking this in with your response, or do you really just go from zero-to-asshole in 2.4 seconds?



  • @C-Octothorpe said:

    @jverd said:

    @blakeyrat said:
    @Xyro said:
    TheCPUWizard, I've noticed that you are very good at working at the wrong level of abstraction...
    Typical pedantic dickery.

    Combined with a healthy dose of, "oh I'm so much smarter than you because you said something that, if taken literally, is wrong, watch me prove how smart I am by correcting it!" The fact that the statement is practically correct doesn't matter.

    You're quoting Xyro, but your comments apply more properly to TheCPUWizard's post that Xyro was commenting on. Was that a quotypo on your part, or are you just truly that clueless?
    I believe he was agreeing with Xyro.

    Ah, I see. Wasn't clear from the post.

    @jverd said:

    or are you just truly that clueless?

     BTW, what the hell was the point of chucking this in with your response, or do you really just go from zero-to-asshole in 2.4 seconds?

    No, I've always been an asshole. :-)

    My impression of blakey so far is that he is an even bigger asshole than I am, and that he may very well be that clueless. Maybe I'm mistaken. He might just be having a really horrible couple of weeks. If I've misjudged him, then I offer hiim and the community my apologies.



  • @jverd said:

    My impression of blakey so far is that he is an even bigger asshole than I am, and that he may very well be that clueless. Maybe I'm mistaken. He might just be having a really horrible couple of weeks. If I've misjudged him, then I offer hiim and the community my apologies.

    No, you are correct but he is a known asshole that sometimes comes with interesting ideas, you on the other hand.... are still an enigma to us



  • @jverd said:

    My impression of blakey so far is that he is an even bigger asshole than I am, and that he may very well be that clueless. Maybe I'm mistaken. He might just be having a really horrible couple of weeks. If I've misjudged him, then I offer hiim and the community my apologies.
    What in the ....

    Who apologizes on the internet?



  • @jverd said:

    My impression of blakey so far is that he is an even bigger asshole than I am, and that he may very well be that clueless. Maybe I'm mistaken. He might just be having a really horrible couple of weeks. If I've misjudged him, then I offer hiim and the community my apologies.
    You're absolutely correct, he is an asshole (or schizophrenic).  But my take is that he isn't being one now, so why poke the sleeping bear?



  • @C-Octothorpe said:

    @jverd said:

    My impression of blakey so far is that he is an even bigger asshole than I am, and that he may very well be that clueless. Maybe I'm mistaken. He might just be having a really horrible couple of weeks. If I've misjudged him, then I offer hiim and the community my apologies.
    You're absolutely correct, he is an asshole (or schizophrenic).  But my take is that he isn't being one now, so why poke the sleeping bear?

    Just trying to beat the holiday rush.



  • @C-Octothorpe said:

    @jverd said:

    My impression of blakey so far is that he is an even bigger asshole than I am, and that he may very well be that clueless. Maybe I'm mistaken. He might just be having a really horrible couple of weeks. If I've misjudged him, then I offer hiim and the community my apologies.
    You're absolutely correct, he is an asshole (or schizophrenic).  But my take is that he isn't being one now, so why poke the sleeping bear?

    I'm definitely an asshole, but I'm more interested in the logic jverd is applying here. If you quote person Foo, then you must be addressing person Foo. So if I quote a movie:

    @Princess Leia said:

    Why you stuck-up, half-witted, scruffy-looking nerf-herder!

    That means I'm now actually addressing Princess Leia!



  • @belgariontheking said:

    @jverd said:

    My impression of blakey so far is that he is an even bigger asshole than I am, and that he may very well be that clueless. Maybe I'm mistaken. He might just be having a really horrible couple of weeks. If I've misjudged him, then I offer hiim and the community my apologies.
    What in the ....

    Who apologizes on the internet?

    MWUAH HA HA! All part of that whole "enigma" thing. Keep 'em on their toes and whatnot.



  • @blakeyrat said:

    I'm more interested in the logic jverd is applying here. If you quote person Foo, then you must be addressing person Foo.

    Talk about interesting logic!

    How the snot did you get from my initial response to you to "[b]must[/b] be addressing whomever"? I would think you would know that it is certainly quite common to quote the person you're addressing or talking about. Your post didn't have anything along the lines of "Yeah, that's how CPUWizard is" to suggest that you were referring to him rather than to the Xyro post you quoted. That combined with the amount of irrationality I've seen in your posts so far makes it perfectly logical that you might have been saying Xyro, not CPU, was the pedantic dick.

    Guess I'll keep that apology in escrow for now.



  • You know what? I've been sick for 8 days. I recently finished busting my ass getting a project done, sacrificing my PTO days and working with tools I hate, only to find the launch has been pushed back an entire week (coincidentally that lines up with exactly how long I told them it would take in the first place, go figure).

    You're not going to troll me today.



  • @blakeyrat said:

    You know what? I've been sick for 8 days. I recently finished busting my ass getting a project done, sacrificing my PTO days and working with tools I hate, only to find the launch has been pushed back an entire week (coincidentally that lines up with exactly how long I told them it would take in the first place, go figure).

    You're not going to troll me today.

    Not even trying to.

    Your "logic" above is total crap, just like other total crap "logic" I've seen from you, so I called you on it. But then, I haven't been around that long, so maybe that 8 days etc. is giving me an inaccurate impression. I can only wait and see, but while I'm aware that I could be wrong I don't have any reason so far to think I actually am.



  • Blakeyrat is easily one of the most entertaining posters on this site.  Being opiniated and vocal comes along with that.



  • @blakeyrat said:

    @Xyro said:
    TheCPUWizard, I've noticed that you are very good at working at the wrong level of abstraction...
    Typical pedantic dickery.

    Combined with a healthy dose of, "oh I'm so much smarter than you because you said something that, if taken literally, is wrong, watch me prove how smart I am by correcting it!" The fact that the statement is practically correct doesn't matter. (Actually, I'm pretty sure the assholes who do stuff like this don't even know what the word "practically" means.)

    Ironically, he was wrong anyway.  A simple google search will show you that threads are indeed used to service interrupts in many OSes.  Also, the Kernel provides threading and task scheduling in most OSes.  Maybe he was trolling (I doubt it).


  • @frits said:

    @blakeyrat said:

    @Xyro said:
    TheCPUWizard, I've noticed that you are very good at working at the wrong level of abstraction...
    Typical pedantic dickery.

    Combined with a healthy dose of, "oh I'm so much smarter than you because you said something that, if taken literally, is wrong, watch me prove how smart I am by correcting it!" The fact that the statement is practically correct doesn't matter. (Actually, I'm pretty sure the assholes who do stuff like this don't even know what the word "practically" means.)

    Ironically, he was wrong anyway.  A simple google search will show you that threads are indeed used to service interrupts in many OSes. 

    Meh, not really.  The actual interrupt itself is handled in interrupt context.  It's true that most modern OSes require the actual interrupt handler to do minimal work (generally clearing whatever hardware flag caused the interrupt and whatever other minor register manipulation the hardware needs) and hand off as much as possible to run in a deferred task in a kernel thread, but that's not really the same as "serviceing" the interrupt in a thread.

    On the other hand, you wouldn't call sleep() in an interrupt handler, so it wasn't really germane to the point.




  • @DaveK said:

    @frits said:

    @blakeyrat said:

    @Xyro said:
    TheCPUWizard, I've noticed that you are very good at working at the wrong level of abstraction...
    Typical pedantic dickery.

    Combined with a healthy dose of, "oh I'm so much smarter than you because you said something that, if taken literally, is wrong, watch me prove how smart I am by correcting it!" The fact that the statement is practically correct doesn't matter. (Actually, I'm pretty sure the assholes who do stuff like this don't even know what the word "practically" means.)

    Ironically, he was wrong anyway.  A simple google search will show you that threads are indeed used to service interrupts in many OSes. 

    Meh, not really.  The actual interrupt itself is handled in interrupt context.  It's true that most modern OSes require the actual interrupt handler to do minimal work (generally clearing whatever hardware flag caused the interrupt and whatever other minor register manipulation the hardware needs) and hand off as much as possible to run in a deferred task in a kernel thread, but that's not really the same as "serviceing" the interrupt in a thread.

    On the other hand, you wouldn't call sleep() in an interrupt handler, so it wasn't really germane to the point.


    http://msdn.microsoft.com/en-us/library/ms892415.aspx

     


  • ♿ (Parody)

    @frits said:

    @DaveK said:

    On the other hand, you wouldn't call sleep() in an interrupt handler, so it wasn't really germane to the point.


    Since you didn't RTFL:
    @MSDN said:

    The OS wakes the IST when the OS has an interrupt to process.

    Now, I'm not an expert on hardware or interrupts, but since this isn't the actual part of the software that first handles the interrupt, you haven't gotten down to the bottom. Except for a lack of reading, I can't see why you thought this contradicted what DaveK said.



  • @boomzilla said:

    @frits said:
    @DaveK said:

    On the other hand, you wouldn't call sleep() in an interrupt handler, so it wasn't really germane to the point.

    Since you didn't RTFL:
    @MSDN said:

    The OS wakes the IST when the OS has an interrupt to process.

    Now, I'm not an expert on hardware or interrupts, but since this isn't the actual part of the software that first handles the interrupt, you haven't gotten down to the bottom. Except for a lack of reading, I can't see why you thought this contradicted what DaveK said.

    Yeah, I'm pretty sure that thing is just a wrapper round a standardised interrupt handler that does the actual interrupt-context business and wakes up the thread:

    @MSDN said:

    When the hardware interrupt occurs, the kernel signals the event on behalf of the ISR




  • Jesus. Even after people pointed out exactly what he was doing, bam, thread totally derailed.

    I give up. I have no idea how to prevent TheCPUWizard from destroying every thread he touches.


Log in to reply