delay

DispatchQueue.main.asyncAfter is inaccurate

南笙酒味 提交于 2019-11-30 20:21:21
I am trying to call a function after a delay. On iOS10 I am able to use Timer.scheduledTimer which does indeed call my closure after the given delay. However, on iOS9 I am using DispatchQueue.main.asyncAfter and it calls my closure with a six second delay. The delay I am testing with is 60 seconds. Timer.scheduledTimer calls closure after 60 seconds, DispatchQueue.main.asyncAfter after 66 seconds. The six second delay is consequent, if I schedule two delays of 60 seconds the second delay is called after 132 seconds using DispatchQueue.main.asyncAfter. func delay(delay:Double, closure:@escaping

Delay a link click

て烟熏妆下的殇ゞ 提交于 2019-11-30 18:23:20
问题 Here's the fiddle I'm working with: http://jsfiddle.net/Scd9b/ How can I delay the href function after the click? For example a user clicks on the link, the message slides down One moment... and after 2 seconds the user continues to the page its linked to. Sorry everybody forgot to mention there are some anchors that are not linked. 回答1: You can simulate navigating to a page by settings window.location. So we will block the normal function of the link with preventDefault and then in a

How to delay showing of progress if ajax takes less than X seconds?

℡╲_俬逩灬. 提交于 2019-11-30 15:34:13
I've got a few AJAX calls on a page. Some complete instantaneously, others take a few moments -- all depending upon what is clicked. I want to add a "loader" that will display after X seconds while AJAX is working on results. I've got a loader working: $(document).ajaxStart(function() { $("#loader").css("display","block"); }).ajaxSuccess(function() { $("#loader").css("display","none"); }); This functions. However, it flashes on screen when the AJAX request is fast... like in the blink of an eye. Other than the "blinking" which occurs, it works great. So, I'm trying to delay the loader css

Trying to fix AVAudioPlayer lag on its initial use

核能气质少年 提交于 2019-11-30 15:22:02
This issue has shown up in several other question here on SO: Slow start for AVAudioPlayer the first time a sound is played Delay in playing sounds using AVAudioPlayer I've tried implementing the fixes suggested but none of them are solving my problem. My application presents the user with a grid of objects to touch, when an object is touched a sound is played. This works great except on the initial touch there is a delay of ~2 seconds. To get around this I initialize my audio player with a dummy aiff file: - (void)viewDidLoad{ NSString *soundFile = [Card loadCardSoundPath:@"dummy"];

I want to delay a link for a period of 500 with javascript

妖精的绣舞 提交于 2019-11-30 14:24:46
I've been looking through the Stackoverflow questions, trying to get help with a simple link delay; I want to put it around a div, and I can't make heads or tails of the examples I've found. So far, I understand that I need to halt the native function of href, but I don't know how to do that. The code is still very alien to me. Help? gurvinder372 Set your href attribute as href="javascript:delay('URL')" and JavaScript: function delay (URL) { setTimeout( function() { window.location = URL }, 500 ); } If you want to delay every link on your page, you can do it with jQuery like this $(function(){

Right way to test page load time in selenium?

﹥>﹥吖頭↗ 提交于 2019-11-30 12:16:28
问题 I'm trying to programatically test the load time of a list of websites. The purpose is to roughly simulate the page load time a user will perceive. My first approach is to call the following inside a loop: startTime = System.currentTimeMillis(); driver.get("http://" + url); diff = System.currentTimeMillis() - startTime; System.out.println("Load time was " + diff); The problem is sometimes I get the time result before the page has really loaded (i.e i get 50ms times) so I guess the control is

give a delay of few seconds without using threads

家住魔仙堡 提交于 2019-11-30 09:34:58
How can I give a delay of few seconds without using threads.some function that I can call anywhere for giving delay. Android built-in function is highly preferred. Thanks Use a Handler, and send either a simple message or a Runnable to it using a method such as postDelayed(). For example, define a Handler object to receive messages and Runnables: private Handler mHandler = new Handler(); Define a Runnable: private Runnable mUpdateTimeTask = new Runnable() { public void run() { // Do some stuff that you want to do here // You could do this call if you wanted it to be periodic: mHandler

delay() and fadeOut() don't delay attr() in the queue

强颜欢笑 提交于 2019-11-30 09:12:54
what is wrong in this code? I'm trying to get this effect: fadeOut(500) and attr('class','myClass') delayed by 600 millisecs.. then delay(600) again, and fadeIn(500) . The delays happen correctly but the attr() is not being delayed, it fires when #myDiv is still fading! :'( $('#myDiv').fadeOut(500) .delay(600) .attr('class','myClass') .delay(600) .fadeIn(500); The .delay() only affects the animation or fx queue (unless you specify a different queue specifically). Keep in mind that chaining and queuing are 2 distinctly different concepts, chaining continues the use of the same jquery set, but

Sleep routine for HTA scripts

人盡茶涼 提交于 2019-11-30 09:07:00
问题 In several of my .HTA scripts that I created, I had the need for the VBScript WScript.Sleep command which simply waits for a number of milliseconds without utilizing the CPU. And when I browse the web, it appears that I am not the only one looking for this: https://www.google.nl/search?q=hta+sleep (I bet that if you read this, you probably need(ed) this as well) The best solution that I could find appears to be the one which uses the PING command. But especially for a situation were just need

Delaying but not disabling iPhone auto-lock

核能气质少年 提交于 2019-11-30 07:35:46
I currently have a very simple app for which the only interaction is shaking the iPhone. However eventually the screen dims and auto-locks since the iPhone is not getting any touch events. I was wondering if there is a way to reset the auto-lock time-out when shaken? I know that to disable auto-lock completely I would do this: [[ UIApplication sharedApplication ] setIdleTimerDisabled: YES ] but I don't really want to disable it completely; if the iPhone is legitimately not being used it should auto-lock as expected. Thanks for your help. You could toggle the value of [UIApplication