| « Prev | Page 1 | Page 2 | Next » |
|
They better have some damn good hold music if i'm waiting that long
|
Re: Patiently Waiting Forever
2007-08-20 09:38
•
by
Frank
(unregistered)
|
|
What's with the int i=1; It's never used!
|
Re: Patiently Waiting Forever
2007-08-20 09:39
•
by
nobody
(unregistered)
|
I'm sure they have something like "The Best of Captain Beefheart" or maybe they went in a different direction with "Lawrence Welk's Greatest Hits" |
It's in the while loop. |
|
Arrrgghhh. How about "Do you know the way to San Jose?" arranged for synth sax mixed with the 30 second chiming in of the company message, "Your call is important to us. Please hold and a representative will be with you shortly."
|
|
Let's pass in a value of 86399 seconds and see what happens.
|
Re: Patiently Waiting Forever
2007-08-20 09:43
•
by
lightinthedark
(unregistered)
|
|
From the looks of it, if you tried to tell it to wait more than a day it'd ignore you and just set max to 86400 * 4 again. How rude! :-)
And the i=0 initialises the counter that gets checked down near the bottom in the while loop ... i < max ... Hello :-Lightinthedark |
It will wait 23 hours, 59 minutes and 59 seconds... |
|
Erm, 6 hours.
And window != IntPtr.Zero seems abusive here. |
they better have one fantastic sales pitch to keep someone on the phone for a week! |
|
You can't put me on hold, I'll put you on hold. (singing) I am a lineman for the county. (speaking) Your call is important to us. Please continue to hold. (singing) And I drive the main road. (speaking) There are…eight calls ahead of you. (singing) And the Wichita lineman is still on the li-li-li-li-li-li-li-li-li-li-li-li-line.
|
|
// 86400 is the number of seconds in a day
int max = 86400 * 4; Since they increase the number of seconds to wait by multiplying it with 4 wouldn't that mean that we wait 4 days instead of just one lousy day. :) I can image the discussion about the wait time: * Hmm how long should we keep trying? - Well maybe a few minutes are enough. * What if the system is VERY busy? - Ok, what about max wait time of one hour? * Set it to a full day and we'll get back to this. ... later - What was it that architect told me? Lets be on the safe side and put the wait time to four days. ... even later - What was it we were supposed to change??? |
Re: Patiently Waiting Forever
2007-08-20 10:27
•
by
N2
(unregistered)
|
Its not 4 days because it tries to find the window 4 times a second, and increments i with each one. (250ms = 1/4th second) |
No, because they sleep for 250 milliseconds, which is .25 seconds. |
|
Perhaps it was BT?
http://www.news.com.au/story/0,23599,22270173-401,00.html |
|
Not only does it use an inappropriate time limit; but it uses FindWindow and ignores a certain result (avoidWindow). What if there are two matching windows and FindWindow always returns avoidWindow? I think that may well be why it doesn't return quickly. This should be using EnumWindows or whatever wrapper .NET has for it. Also, messing with other process's windows is something of a WTF (window handles aren't ref-counted!) though sadly it seems to be necessary too often on Windows.
|
|
The Real WTF is the analysis of this code...
It tries every 1/4 second to find the window, for a full day. The fact that it gives a full day time before it gives up is a bit of a "Hmm", but not a WTF. Captcha: poindexter |
|
Seems like you pass a maximum amount of time you're willing to wait. The maximum time that can be is 1 day. Doesn't seem so ridiculous...Yeah, a day's a bit long, but the max has to be somewhere, and this guy is expecting a smaller value to be passed. At least he's doing some sort of input validation.
|
You always give a non-responsive application 25 hours to recover before you declare it dead? I bow in respect of your patience. Using an infinite loop would have had exactly the same effect for the user. Waiting a full day is clearly a WTF. |
|
And as usual; the real WTFs are the comments..
|
Re: Patiently Waiting Forever
2007-08-20 10:49
•
by
homer
(unregistered)
|
Best obscure simpsons reference ever! |
Re: Patiently Waiting Forever
2007-08-20 11:02
•
by
wtf
(unregistered)
|
|
But a full day is only the default, and the max accepted interval. Callers can provide a shorter interval if they want.
What's wrong with this? It seems the real WTF isn't in the code shown, but in the calling function, and that it relies on the default. Still not a big deal. A bigger WTF in my book is the way he measures time - a certain number of sleep(250) can't be accurate: clock resolution rounding might make each sleep actually 233 or 266ms or some other arbitrary period; the surrounding code also takes time to execute; there may be other delays caused by other processes or I/O; also, perhaps (not sure on windows) sleep can be interrupted earlier by signals and such. |
Re: Patiently Waiting Forever
2007-08-20 11:06
•
by
Andrew
(unregistered)
|
I think "The Theme From Shaft" is almost long enough that it won't repeat. |
|
The code is already optimized and noone sa<w it. It uses the upper bound of the if statement. This means it will NOT multiply the timer by 4. So effectively it will only wait 8 H with the call...
But if you pass in 1 second LESS, then you will increase the waittime by almost 300%... |
|
Would this happen to be for the cable company?
|
|
It's behavior is "I will wait a day unless you give me a time less than a day.", which is fine (other than being a large maximum).
i.e. It is setting "max" to be the 4 * minimum of (maxWaitInSeconds and dayInSeconds) |
Re: Patiently Waiting Forever
2007-08-20 11:13
•
by
Andrew
(unregistered)
|
There is a Tom Petty song that comes to mind too. |
Re: Patiently Waiting Forever
2007-08-20 11:17
•
by
jkupski
(unregistered)
|
No. If it was, the max wait time would be random, and there would be a 20% chance of dropping your call on every iteration of the loop. And remember, folks: when the cable company says "We'll be there Friday, 9-1" they aren't telling you when they will arrive... they're quoting odds. |
Re: Patiently Waiting Forever
2007-08-20 11:26
•
by
Andrew
(unregistered)
|
ROLFLMAO, coffee through nose, pee in my pants, and puke! |
Re: Patiently Waiting Forever
2007-08-20 11:29
•
by
woofles
(unregistered)
|
Try again: 'max' is initialized to '86400 * 4' so it will wait a day, not 8 hours. |
Re: Patiently Waiting Forever
2007-08-20 11:35
•
by
Cloak
(unregistered)
|
lol |
Re: Patiently Waiting Forever
2007-08-20 11:35
•
by
Cloak
(unregistered)
|
lol |
Re: Patiently Waiting Forever
2007-08-20 11:36
•
by
dkf
(unregistered)
|
Or AT&T? (Motto: We don't have to care, we're the phone company.) |
Re: Patiently Waiting Forever
2007-08-20 11:49
•
by
nobody
(unregistered)
|
For a while, ATT No-Broadband was my cable company. A few people actually were able to get to customer "service", after waiting over 40 minutes. Just about everyone else gave up. |
|
public static IntPtr GetWindow(string className, string title,
int maxWaitInSeconds, IntPtr avoidWindow) { IntPtr window = IntPtr.Zero; int max = 86400 * 4; int i = 0; // 86400 is the number of seconds in a day if (maxWaitInSeconds < 86400) { max = maxWaitInSeconds * 4; } window = Win32API.FindWindow(className, title); while ( ((window == IntPtr.Zero) || (window != IntPtr.Zero && window == avoidWindow)) && (i++ < max)) { Thread.Sleep(250); window = Win32API.FindWindow(className, title); } return window; } Actually, this code seems to suggest that it will wait up to a day for a handle to a window. It apparently tries 4 times per second. A bit silly, but this seems like a small matter compared to enum x {yes=0,no=1} |
Re: Patiently Waiting Forever
2007-08-20 12:07
•
by
Mexi-Fry
(unregistered)
|
Clarification: UP TO... to be sure that I said it right. If the window was closed and is no longer retrievable, then the application will never pass that point, but if it manages to get a reference in the first second, or ten minutes it will. Still seems silly to me... but a training issue could get around that bug. |
|
TRWTF is the math skills of the people commenting:
1. There are 86400 seconds in a week. 2. There are 31 hours, 59 minutes, 59.75 seconds in a day. 3. Code on Windows that calls Sleep(250) 86400 times will take only one day to execute. |
|
http://www.shortnews.com/start.cfm?id=64390 |
Re: Patiently Waiting Forever
2007-08-20 12:28
•
by
Andrew
(unregistered)
|
Well, there's a missing segment of code while (customer.minutesLeft() > 0) { music.play(); announcer.annoy(); // Tells the customer how important they are ringer.trickRing(); } |
Re: Patiently Waiting Forever
2007-08-20 12:30
•
by
Andrew
(unregistered)
|
60 * 60 * 24 = 86400 |
Re: Patiently Waiting Forever
2007-08-20 12:49
•
by
Someone You Know
|
Unless a week on your planet is equal to one Earth day, you need to check your math. |
Re: Patiently Waiting Forever
2007-08-20 12:51
•
by
gomer
(unregistered)
|
Exactly. One week. Sheesh. |
He was remarking on "the math skills of the people commenting". I think he himself is aware of the correct significance of the number 86400. |
Re: Patiently Waiting Forever
2007-08-20 13:12
•
by
herman
(unregistered)
|
I knew the rotationspeed of the Earth was retarding but that it was now 8 hours longer then when I was born in 1951 I did not know. Thanks for this insight |
|
This should actually wait longer than a day (unless it finds the window) because of scheduling delays and the time it takes to execute the loop 86400 * 4 times. 86400 seconds that's just the raw sleep() time.
The times they are a'changin'. |
|
Yeah, count me in as another person who didn't know there were more than 24-hours in a day....
|
|
Does nobody understand Zygo's comment?
|
|
If we had 32 days, and the days were composed of 32 hours with 64 minutes, each containing 64 seconds, each containing 1024 milliseconds, then each month would start at 0x...00000000 and end at 0x...ffffffff. It'd be cool and thrilling and generally nifty, and programmers could tell the time.
My name is arty, and I approved this message. |
|
Assuming the following specification, the code is correct:
If you want to get the handle of a specified window by title, but not if it is a certain window handle you already have, and you only want to wait a specified number of seconds, then call GetWindow( <classname>, <title>, <seconds>, <butNotThisOne> ) Note: If you pass a time period that is more than 24 hours, it will be truncated to 24 hours. Your application never passes a time anywhere near that long. If it does, there's a coding error, and the very long default insures that you will notice the problem while testing (especially as this a telco, and "testing" is performed by the customers during the first few days after deployment). But if you want to get the handle of a specified window by title, and will accept any window handle, and you are willing to wait "forever", then call GetWindow( <classname>, <title> ) Note: it won't wait forever, but will wait 24 hours. Since you only use this call one time, during application startup, there should be no problem, If the application fails to start, you have a whole day to hunt down the frozen process and find out what went wrong. -Harrow. |
Re: Patiently Waiting Forever
2007-08-20 16:23
•
by
Mogri
(unregistered)
|
It's odd that everyone gets hung up on point 1 and misses point 2. I'm not sure what Zygo was getting at, but he wasn't being serious. None of the three points above is correct. |
| « Prev | Page 1 | Page 2 | Next » |