delay

Delay automatic url redirect with jquery?

为君一笑 提交于 2019-11-29 00:29:45
问题 I need a transition page that will display for 2 seconds before automatically redirecting to the home page. How do I do this? I can't seem to get delay to work for me. 回答1: You can just use setTimeout() directly, like this: setTimeout(function() { window.location.href = "/NewPage.aspx"; }, 2000); 回答2: setTimeout(function(){ window.location = "/NewPage.aspx"; }, 2000); 回答3: You could use jQuery Timer. Here is the code (also found in this article): // This will hold our timer var myTimer = {};

Need microsecond delay in .NET app for throttling UDP multicast transmission rate

被刻印的时光 ゝ 提交于 2019-11-29 00:10:10
I'm writing a UDP multicast client/server pair in C# and I need a delay on the order of 50-100 µsec (microseconds) to throttle the server transmission rate. This helps to avoid significant packet loss and also helps to keep from overloading the clients that are disk I/O bound. Please do not suggest Thread.Sleep or Thread.SpinWait. I would not ask if I needed either of those. My first thought was to use some kind of a high-performance counter and do a simple while() loop checking the elapsed time but I'd like to avoid that as it feels kludgey. Wouldn't that also peg the CPU utilization for the

Delays between promises in promise chain

喜夏-厌秋 提交于 2019-11-28 23:38:30
Let's say I am using the following code to run a couple of promises in series: let paramerterArr = ['a','b','c','d','e','f'] parameterArr.reduce(function(promise, item) { return promise.then(function(result) { return mySpecialFunction(item); }) }, Promise.resolve()) The code simply calls mySpecialFunction (which returns a promise), waits for the promise to be resolved and then calls mySpecialFunction again etc. So the function is called once for every element in the array, in the correct order. How could I make sure that there is a delay of at least 50 milliseconds between every call of

delay() or timeout with stop()?

こ雲淡風輕ζ 提交于 2019-11-28 21:18:14
$('.file a').live('mouseenter', function() { $('#download').stop(true, true).fadeIn('fast'); }).live('mouseleave', function() { $('#download').stop(true, true).fadeOut('fast'); }); I want the mouseenter function to have a stop() and a delay of 1 second. So, if I hover over #download the fadeIn should start after a 1 second delay. If I mouse out meanwhile the fadeIn shouldn't start. Get me? I don't really know how to do that, any ideas? You need to use setTimeout() in this case because of how .delay() works (and your inability to cancel it). $('.file a').live('mouseenter', function() { $.data

OnKeyUp JavaScript Time Delay?

无人久伴 提交于 2019-11-28 20:22:44
Hi Again Masters Of The Web :) Now, I have got a new stupid question, and I am asking to forgive me. I read everywhere about this solution, but didn't find the one that works for me. I have got: <input name="domain" type="text" id="domain" onKeyUp="javascript:chk_me();"> All I am asking is how to make this not to check after a button is pressed, but after to say 1000 miliseconds of keyboard inactivity? mck89 Try this: var timer; function chk_me(){ clearTimeout(timer); timer=setTimeout(function validate(){...},1000); } In this way every time a key is pressed, the timeout will be deleted and the

How to create delay function in QML?

二次信任 提交于 2019-11-28 19:56:18
问题 I would like to create a delay function in javascript that takes a parameter of amount of time to delay, so that I could use it do introduce delay between execution of javascript lines in my QML application. It would perhaps look like this: function delay(delayTime) { // code to create delay } I need the body of the function delay() . Note that setTimeout() of javascript doesn't work in QML. 回答1: As suggested in the comments to your question, the Timer component is a good solution to this.

jQuery: Wait/Delay 1 second without executing code

时光毁灭记忆、已成空白 提交于 2019-11-28 15:41:15
I can't get the .delay method working in jQuery: $.delay(3000); // not working $(queue).delay(3000); // not working I'm using a while loop to wait until an uncontrolled changing value is greater than or equal to another and I can't find any way to hault execution for X seconds. $.delay is used to delay animations in a queue, not halt execution. Instead of using a while loop, you need to recursively call a method that performs the check every second using setTimeout : var check = function(){ if(condition){ // run when condition is met } else { setTimeout(check, 1000); // check again in a second

How do I make this java for loop pause for 1/2 a second between each iteration?

China☆狼群 提交于 2019-11-28 14:41:28
private class MultipleGensListener implements ActionListener { public void actionPerformed(ActionEvent e) { for(int i = 0; i < 25; i++) { game.runSimulationOneGen(); changeGrid(); } } } //this is the loop. The changeGrid method displays a game grid on a GUI but // only the 25th iteration is visible on screen. I would like each one to be // visible for about a half a second before the loop continues. // I have seen some questions answered on here that are very close to what I'm asking, // but I just don't really understand how to apply it to my program.. // thanks for any help. If the code

Checking condition and calling continuous method with periods of delay unity

狂风中的少年 提交于 2019-11-28 14:39:37
I want code to check if target is alive, and if yes shoot at it. I want to check it all the time, and shoot all the time, The only problem is that checks can be made anytime u want, but shooting must have limits of fire per second. I mean u check the target all the time, but when u decide to shoot, bullets will fire one after another with some delays. And also when u realize that target is dead u stop shooting at the same time. void Update() { StartCoroutine(Shoot(currentTarget, 1f)); } IEnumerator Shoot(Collider currentTarget, float delayTime) { yield return new WaitForSeconds(delayTime); if

Dismiss UIAlertView after 5 Seconds Swift

我的梦境 提交于 2019-11-28 14:30:28
问题 I've created a UIAlertView that contains a UIActivityIndicator. Everything works great, but I'd also like the UIAlertView to disappear after 5 seconds. How can I Dismiss my UIAlertView after 5 seconds? var alert: UIAlertView = UIAlertView(title: "Loading", message: "Please wait...", delegate: nil, cancelButtonTitle: "Cancel"); var loadingIndicator: UIActivityIndicatorView = UIActivityIndicatorView(frame: CGRectMake(50, 10, 37, 37)) as UIActivityIndicatorView loadingIndicator.center = self