« first day (43 days earlier)      last day (5131 days later) » 

01:35
mvc question: how stackoverflow implemented their login page "http://stackoverflow.com/users/login" if you clicked login with empty openid, you will get the error message, and if you refreshed it is not asking for repost data again
 
2 hours later…
03:51
@AmrElGarhy : en.wikipedia.org/wiki/Post/Redirect/Get . There's also dozen's of questions/discussions on this pattern on SO
 
7 hours later…
10:43
Hi.
Anyone here familiar with Windows Forms?
 
6 hours later…
16:35
hello?
Still no one..
i figured this would be hoppin
Hey, can you help me?
I need to know that when I stop my timer with timer.Stop(), and then start it again with timer.Start(), should the timer start immediately, or is there half a second pause in between?
17:00
beats me, I do asp.net exclusively
17:17
Darn.
 
1 hour later…
18:26
should start immediately
but the event itself, of course, fires after the interval you set
also if you use the WinForms Timer, you are depending on windows messages
so if your gui is to busy, your timer event can be raised a bit later
or never
18:51
I used System.Timers.Timer
And the interval is set to 30 ms, so it should start immediately.
But it doesn't, there's a slight pause before it starts.
that one uses threads
I presume your Elapsed event handler is thread safe?
how do conclude there is a pause before it starts? And how big is the pause? How big is your interval?
Well,
I have an object that is moving around in Windows Forms.
The movement of the object is animated inside a timer, that is called every 30 ms. The timer starts on KeyDown event, and stops on KeyUp event.
So, if I press down for example left, and then immediately after I release the left key and press another one, there's a slight pause (about half a second), before it moves in that direction.
That problem does not appear, if I hold left, the release it, and wait a little bit, and THEN press right. In such case, it would immediately move right.
It also doesn't appear if I am holding down left, and then start holding down right, while I'm still holding left. In that case, it would start moving right immediately, too.
The problem only appears, when I release the key and immediately press another one afterwards.
I am not aware of any reason for the system.timers.timer to react that way
but if you ask me, I would handle it different
How?
I need a timer, so that I can properly animate the movement of the object.
I am no gaming expert, but I suspect it might be easier to just have one heart beat in your game
oh wait, is it a game you are programming?
19:04
Yeah.
why not have just one timer firing every x milliseconds and do all your logic there
is a key pressed? then move.
wait x ms, is a key pressed? then move again
Key pressed event is troublesome when it comes to checking if arrow keys are pressed.
Which is why I used KeyDown
I suggest not using any events other then the timer Elapsed
How am I supposed to find out if for example left key is pressed inside a timer, then?
not what class to use in WinForms, but you don't need events for that
it seems WinForms does not have such a class. But you could P/Invoke a win32 function: pinvoke.net/default.aspx/user32.getkeystate
19:12
I rather.. wouldn't do something that I wouldn't quite understand.
talking about that...are you sure your code is thread safe?
so that also might be something you wouldn't quite understand?
I guess so.
then you maybe shouldn't do that either :)
using the WinForms Timer is easier, because it doesn't use different threads
it is also less acurate
19:18
WinForms timer somehow didn't work when I tried it, and people on stackoverflow suggested me to use Timers.Timer instead.
then please make sure you understand the implications
sorry, but I guess I can't help you answer your question
I understand.
you might want to try and ask it on stackoverflow.com and see if other people can come up with answers
0
Q: System.Timers.Timer problem with starting after another key is released

NoelAramisHello. I have a WinForms program, where I have a certain animated object that moves around when I press Up, Down, Left and Right. The movement of the object is animated inside a timer, that is called every 30 ms. The timer starts on KeyDown event, and stops on KeyUp event. So, if I hold for exa...

hehe, same warning :)
I see you also posted your code
some tips: you first start the timer, then set the direction. Since the timer might elapse before you set the direction, you might want set the direction before you start the timer
19:30
Okay, will do.
but really, your code is not thread safe at all. You should feel lucky it even runs without errors
What am I supposed to do?
writing thread safe code is not that easy
the easiest is not the use multiple threads at all
Well, I gotta learn how to do it at some point, so I might as well learn it now.
if you really want/need multiple threads, then you should learn about the subject
then if you really understand it you might think about using multiple threads
there really is no need for you to use multiple threads for a simple game
19:34
I will need threads eventually, once I put in things like background music etc.
can be done without threads
without you using extra threads explicitly
really, most games don't use multiple threads
What about when you want to more people to connect, and if you have a server?
server, yes, then you have threads. But that is not the same engine as the game
but anyway, writing thread safe code is not something that can be explained in one or two lines
the easiest would be the have the Elapsed event handler switch over to the GUI thread
but that basically would be the same as using the WinForms timer
19:40
Well,
I used Windows.Forms.Timer now, instead of the Timers.Timer now
And it works exactly the same.
great
one problem less
It's still a problem.
you don't have any threading bugs anymore
I would suggest stripping your code
I wouldn't be surprised the problem is your own code
also easier for anyone to help you with your problem
Well, naturally, I'm still quite a newbie.
nobody is going to debug that much code you posted
19:47
Did that.
ok, great
reduced it to three lines of code?
Well, what was inside, was basically movement.
I saw a change of interval inside the timer elapsed handler
I saw two timers
saw lots of if statements
Those timers you saw were the delegates I had to use, they weren't real timers, just named that way.
The interval changes were not really changes,since the interval is the same all the time.
really, my advice is to strip your code and try again. Get to the bear metal of this problem
until you have the least number of lines and still have the problem
19:56
I kinda tried that already.
I had nothing else in it but the bare movement and it still did it.
so show that code
not the code with all the distractions. What is 'k' anyway?
Well.. did you see in keyUp event that there's an if clause if watch > 180 ms?
Meaning, that if I only press the button momentarily (and don't hold it down), then the timer will only fire 6 times (and the k is keeping track of that), so that the character moves just a bit before it stops.
That works perfectly, so you don't have to pay attention to it.
or it might be the source of your problems
I deleted it, and it worked the same.
So, you can ignore it.
Could delegates be messing with it?
I've just figured something.
If I don't use the timerMove.Stop() method, then there's no pause in between pressing two keys, but of course the animation still goes on, so it's like the character is auto-moving..
20:15
Guys, question. Can you think of a an API (.NET or otherwise) that you've seen where a class has nested classes in a public API? ie. a public class like LongestCommonSubstring<T>, and instead of having a separate class for the results from it, it has a nested class Result?
so you would have LongestCommonSubstring<string>.Result for a result class typed to strings.
Instead of LongestCommonSubstringResult<string>
FxCop warns about it, I just wanted to know if it was something I could ignore
@LasseVKarlsen: Can't think of any
wouldn't do it myself though
Any particular reason?
nested classes are rarely used by the average developer so they wouldn't understand it as easy
and why would you not rather have two non nested classes?
do the advantages outweigh the disadvantages?
can't think of a real advantage of using public nested classes
I can see the advantage of using private nested classes, yes
Check my code now, Lars, I made it as simple as that and it -still- works the same.
20:31
how about even stripping out the different directions?
What do you mean?
lose the if statements
and lose the Interval = 30
lose k
then you have the 3 lines of code I suggested earlier :)
oh, and lose watch
Still works the same.
This is something about the Start and Stop method.
20:33
if you still have the problem then it is so easy: everyone could have try for them selfs
I'm sure of it.
?
ok, I'll give it a try here. A WinForms app and one timer. keydown does timer.start and keyup does timer.stop.
that is basically what you said reproduces the problem
Yes.
And when timer is active, every 30 ms, the object moves.
I'm using the WinForms timer
Me too.
I hope you realize what my problem is.
20:37
you hope that I have the same problem as you :)
which I kinda doubt
The problem exactly when I hold a certain key, and then release it and press the other one immediately afterwards
Just like how you usually move in the games. You don't press one key, then release it, and then wait to press another key.
you are right
I can see it
I think that's because, when I release a key, it stops the timer, and if I press it immediately afterwards, it can't start it so soon.
So there's a small delay.
But that's just what I think, I'm not sure if that's the case.
no, that is not the case
What is, then?
20:43
try this:
type in a letter in this reply box and keep pressing it
what does it do?
It keeps appearing?
What does that have to do with it?
but what happens between the first and the second letter?
is there a pause?
not really.
20:45
a longer pause then between the later letters?
Oh
There is.
yes, really
Damn..
What should I do, then? =/
what was the first suggestion I made?
I can't remember now, there were too many.
20:49
well, look it up :)
You mean, the thing about checking all the time if the keyDown is still pressed?
And not having keyUp at all?
I could set a boolean in the keyDown, saying that keyPressed = true, but then I dunno where I'd set it as false.
Because if I set it as false inside the keyUp event, it's all the same.
no, that was not my advice, but you are close
why not have just one timer firing every x milliseconds and do all your logic there
is a key pressed? then move.
wait x ms, is a key pressed? then move again
That?
You know, you never told me how to know inside a timer, if a key is pressed.
yes
I did
That link you gave me, is slightly complicated.
Is there no other way?
20:55
@NoelAramis right below this
Is there no other way?
yes, in stackoverflow I gave another suggestion which is more work, but you don't need to call GetKeySate
Can you link me to that, please?
you know the link :)
it is your question silly
Thanks.. I'll have to go now..
20:58
You know how to thank me :)
vote for my answer
and accept it if it is the right answer
I'll give you a vote up, and if I manage to solve this issue with your suggestion, I'll put it as answered.
thanks
And if you are wondering how I figured it out: I logged the key downs and key ups and noticed the delay originating there and not in the timers.
21:45
Hey guys may I ask you how to extract bit value from an integer when reaching given position using bit operators?
(number>>position)
don't think I'm following you
>> is a shift right
yes
and extracting bit values is usually done using a bit mask
using and (&)
why do you think they are connected?
if (a & 1 == 1) // Bit 1 is set
Yes I know this but it seems more of a bool check than real extracting and assign
if (a & 2 = 2) // Bit 2 is set
there is no extracting and no assigning
21:51
You mean I can extract directly the value of a bit in a number and assign it the an integer giving it value 0 or 1?
*can't
maybe you should rewrite your question. This one does not make sense
or even better: tell me what you really want to do. Why would you need to 'extract' bits using bit shifting?
what does extract mean anyway? sounds like it would remove a bit. Which is nonsense
a byte is 8 bits. Nothing to remove there. You can change the value of a bit though
Well this is what the assignment text says
to extract
well, then I suggest looking up on your boolean algebra and guess what the assignment means :)
can't help you with that
ok
10x
& to get a value and | to set a value
>> and << shift right or left
can't help you interpreting the assignment :)
22:00
Well I'm familiar with that approach but in my assignment it corresponded to "return"
Now it is "extract"
whatever it is
Guys, I need suggestions for a good name
I'm writing a text diff implementation, similar to what you'd get from kdiff or beyond compare, comparing text files
I think yours is just fine :)
if I have a class containing a single line from each file, but the comparison results for those two lines could be that they are equal, the line from the new file was inserted, the line from the old file was deleted, or the line from the old file was replaced with the line from the new file
I need a property holding an enum saying all of that
ie. added, deleted, replaced, or same/equal
The name of the type that will hold that property + the two lines is called TextDiffLine (for now), any suggestions what I could call the enum and/or property that would make sense?
TextDiffLineType or TextDiffLineAction seems kinda lame to me
ChangeType
22:06
thanks :)
though since it is highly localized, I will call it TextDiffLineChangeType
or should I not, because this is in my namespace anyway?
come to think of it, I should try to make this more generic than just for text-files, the way I handled the other diff classes in this library
so "TextDiff" will have to go
not sure. I do like to use namespaces, but if the class get used a lot with other classes with the same name it is still not handy
but in this case I think I would use the namespace and shorten the names
ok, I'll go with that then :)
not much chance on another DiffSomething
22:25
ok, yet another question
if you had two strings, and could produce a diff between the two that said whether a range of characters was same, inserted or deleted, would a good "similarity ratio" be to calculate how many characters was the same between the two against their total length?
for instance, if half the content of the first string was equal to content in the second, that would be a similiarity of 0.5?
I'm also thinking that perhaps I should calculate the "same-ness" against their combined lengths, so that if I just insert or delete content, that would have an effect as well
Hi
is it possible to set stackoverflow that when new question with tag that I choose apears I get email notification ?
I think you can only have mail triggering on questions
But all tags should have an RSS feed, would that be enough?
If your email client has support for RSS feeds you could add the feed into that, and it would be somewhat like an email
Sure
But where can I find adress of taht rss feed for each tag ?
At the bottom of the right-hand menu of the tag page
There should be a link with an RSS icon
That's the link for the Mercurial tag
Oh yes
...
sorry for that
22:38
If I'm not mistaken, you can get RSS feeds from all search results
I was only looking at the top of each page :/
ok thanks
and the second question
If we are talking about C# and winforms
which is related to the one: stackoverflow.com/questions/4294231/…
Could anyone of You give me any advice
Sorry, not me
on that problem, W was googling and the one thing I found is that probably I will have to inherit from ControlList
ah ok
anyway thank You very much, bye
23:26
Nice, my diff implementations seems to be working :)

« first day (43 days earlier)      last day (5131 days later) »