javascript's setTimeout equivalent in windows forms?

  • Thread starter Thread starter Marina Levit [MVP]
  • Start date Start date
M

Marina Levit [MVP]

Does anyone knows if this exists? Basically, a way to tell a method to
execute, but a certain amount of time after the current event chain is
finished - not immediately. With setTimeout, even if it says to execute in a
second, that is really a second after the entire call chain is finished. So
if the call chain happens to take 10 seconds to complete - the setTimeout
method will execute in 11 seconds.

Timers just execute at regular intervals, but no way to know if the UI
thread is still processing an event when trying to invoke a method on the UI
thread.
 
Marina,

Probably a wrong answer, but what I do forever with a timer is set it to
false in the begin and enable it at the end in the timer event itself, is
this not what you mean?

Cor
 
Marina,

To add, this is why I try to avoid the system.system or the threading timers
as some people like more.

Cor
 
Well, consider when a third party component raises an event that you handle.
At the end of your handler you enable the timer.

However, the third party component that raised the event is still doing some
sort of processing that is taking time.

The question is, would the timer go off in the middle of the component
finishing up it's processing? It would go after the handler completes, but
not necessarily after the component is done what it is doing.

Need something that would go off after the component is completely done with
its call chain.

I'm not sure, maybe timers do work this way? It didn't seem obvious that
they did.
 
Marina,

You sounds almost like a woman.

You go shopping, buy something and pay and you have no money anymore.

Now you go again into the shop but don't know how to pay it.

:-)

That is in my opinion not as the timer event in javascript works.
That starts a procedure which starts itself again at the end where it tells
to do that again at the end.

In my idea in the same way as I showed you.

Timer Tick Event
Timer.stop 'I wrote enable = false
bla
bla
bla
Timer.start
End sub.

Cor
 
Well, I happen to be a woman!

However, I don't really follow the analogy..

In any case, setTimeout has some very specific behavior in javascript, but
it is convenient in terms of making sure that the code you want to runs,
only runs after absolutely everything else that has been started has
entirely completed. It does not run on a separate thread - it turns on the
same thread, but only after that thread is done doing everything.
 
Marina,

That does my sample as well, I see not what is miss than with it?

Cor
 
Marina,
Well, I happen to be a woman!
I never had any doubt in that, I was just kidding.

:-)

The analogy was meant that it became a little bit not logical for me,
something I am not used from you.

:-)

Cor
 
Back
Top