|
Isn't that the definition of legacy code?
|
|
|
|
|
I cant overlook that it would have been so much easier to keep the datatable in the session rather than mangle it as a colon csv, there must have been a good reason... then again we see this stuff on DailyWTF.com all the time
|
|
|
|
|
function sleep(milliSeconds) {
var startTime = new Date().getTime();
while (new Date().getTime() < startTime + milliSeconds);
}
function verifySleep(milliSeconds) {
var startTime = new Date().getTime();
sleep(milliSeconds);
alert('blocked for ' + ((new Date().getTime()) - startTime) + ' milli seconds');
}
|
|
|
|
|
What's wrong with that? That's how scroll lock was implemented in the original PC BIOS (and no doubt a zillion clones). Back in the good ol' days, IBM actually published BIOS listings!
Cheers,
Peter
Software rusts. Simon Stephenson, ca 1994.
|
|
|
|
|
Presumably the intention is to suspend the thread and not hog the CPU, in which case you should use setTimeout.
|
|
|
|
|
Missed the joke icon?
Software rusts. Simon Stephenson, ca 1994.
|
|
|
|
|
yeah
|
|
|
|
|
I just got an answer[^] downvoted in Q&A because I used & instead of && in this line:
if(UsernameTextBox.Text == "Manager" & PasswordTextBox.Text == "Maintenance")
I'm still waiting for a response to my "Why?"
|
|
|
|
|
I don't know who voted you down, but there is lot of difference between using & and && in an if statement. & is a bitwise operation and && is the logical operator.
|
|
|
|
|
So, are you saying you can't use & in that case?!
They do the same except for the fact that && is short-circuited.
|
|
|
|
|
I don't know which language you are talking about, but in C#, they have different meaning, bitwise operators and logical operators are not the same. And in C# all logical operators always short-circuit.
|
|
|
|
|
You're wrong, they don't always short circuit. See here[^] and here[^].
If you're working as C# developer I think you should RTFM.
|
|
|
|
|
|
Shameel wrote: And in C# all logical operators always short-circuit.
You said all logical operators always short-circuit and that's not true. & and | are logical operators and they don't short-circuit. I never said & can't be a bitwise and but in this case it is a logical and .
|
|
|
|
|
I am tired of explaining to you, & is NOT a logical operator, it is a bitwise operator.
|
|
|
|
|
So, in this case - if (true & false) - & is not a logical AND?
|
|
|
|
|
It is your mistake that you are using & like a logical operator. It is NOT supposed to be used as a logical operator, we have && for that purpose.
|
|
|
|
|
Again, you're wrong, they are both logical operators in that case but one is short-circuited and the other is not!
You have the same think in VB with the And , AndAlso , Or , OrElse operators, they are all handy in different situations.
|
|
|
|
|
Please read the msdn links that you posted, VB is different and C# is different. VB has two logical operators for AND operation, And does not short-circuit and AndAlso short-circuits. This is a design decision for backward compatibility with VB6. But C# was designed from the ground-up, so the designers were not constrained by the need to be backward compatible, they had more freedom which made them design && to always short-circuit.
Read this link which CLEARLY states that & and && are different:
http://blog.dmbcllc.com/2009/03/16/vs-and-vs-whats-the-difference/[^]
If you're still not convinced, then good luck to you, this is my last reply to this post.
|
|
|
|
|
What you don't seem to realise is that I'm not talking about the operators names but what they do.
From MSDN[^]:
& - logical AND
| - logical OR
&& - conditional AND
|| - conditional OR
From MSDN[^]:
The operation
x && y
corresponds to the operation
x & y
except that if x is false, y is not evaluated (because the result of the AND operation is false no matter what the value of y may be). This is known as "short-circuit" evaluation.
Which means I was right in my first post to say there was no difference, in that if condition, to use one or the other, the program still runs with no exceptions and as expected.
Your only argument so far is that one is called logical and the other bitwise which doesn't change the fact that I was right; call them what you want.
|
|
|
|
|
This is true only in case where the operands of & are both bool , but unlike && which takes only bool operands, & can also take int as operands which can lead to unexpected behavior.
|
|
|
|
|
And what's the case on the line of code in my first post?
|
|
|
|
|
Your case is an exception, don't treat it like a rule.
|
|
|
|
|
So are you admitting you were wrong?
I may or may not be responsible for my own actions
|
|
|
|
|
'AND' in VB is not equivalent to '&' in C#, but equivalent '&&'. this is applicable for OR also...
Only difference is 'AND' is not short circuited where '&&' is short circuited. To achieve short circuited and VB require explicit usage of 'AND ALSO'
|
|
|
|