wait

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

Wait a time - Android

孤者浪人 提交于 2019-11-28 14:16:09
I want that my program wait 10s in my while true, but it doesn't work I tried to use Thread.sleep(10000); but it isn't 10s while (true) { for (int i = 0; i < 2; i++) { for (int j = 0; j < 5; j++) { if (matrixVacancy[i][j] == 1) { completeParking(i, j, R.color.vaga_ocupada); } else { completeParking(i, j, R.color.cor_chao); } } } try { Thread.sleep(10000); } catch (InterruptedException ex) { } int a, b, c, d, e, f, g, h, i; a = (int) (Math.random() * 2); // indice i b = (int) (Math.random() * 5); // indice j c = (int) (Math.random() * 2); // tem ou nao carro d = (int) (Math.random() * 2); //

Waiting in android app

让人想犯罪 __ 提交于 2019-11-28 14:08:52
So I'm using in my android program A thread to wait a second or more, but sometimes it does it wright and sometimes it doesn't wait at all, so is there maybe another way to wait a couple of seconds? Thread logotimer = new Thread(){ public void run(){ try{ sleep(1500); Intent leveloverview = new Intent("com.technopolisapp.FROGLEVEL"); startActivity(leveloverview); } catch(InterruptedException e){ e.printStackTrace(); } finally{ finish(); } } }; logotimer.start(); vishesh chandra Instead the thread sleeping concept you can use Handler... new Handler().postDelayed(new Runnable(){ public void run(

How to add a “sleep” or “wait” to my Lua Script?

时光毁灭记忆、已成空白 提交于 2019-11-28 13:21:54
I'm trying to make a simple script for a game, by changing the time of day, but I want to do it in a fast motion. So this is what I'm talking about: function disco ( hour, minute) setTime ( 1, 0 ) SLEEP setTime ( 2, 0 ) SLEEP setTime ( 3, 0 ) end and so on. How would I go about doing this? Lua doesn't provide a standard sleep function, but there are several ways to implement one, see Sleep Function for detail. For Linux, this may be the easiest one: function sleep(n) os.execute("sleep " .. tonumber(n)) end In Windows, you can use ping : function sleep(n) if n > 0 then os.execute("ping -n " ..

jQuery - Wait till background images have loaded then show element

♀尐吖头ヾ 提交于 2019-11-28 12:35:57
I did find a few places where it was told how to do this but it was either super inconvenient or just didnt work.. ( the guys own example did not work.. ) Basically i have background images that i would like to show at the same time instead of letting them to load in to the document when ever they please... I dont necessarily need them to be loaded first or anything but to wait until specific background images load up and then show their parent div.. Also if its possible.. it would make big difference if those background images could be defined to be loaded through classes rather than

In Windows batch loop, how to wait for spawned processes to complete before continuing

允我心安 提交于 2019-11-28 12:31:38
问题 I want to fire off multiple commands within a loop in a batch file like this: for /l %%x in (20170101,1,20170105) do ( start /wait C:\Progra~1\Amazon\AWSCLI\aws s3 cp s3://bucket1/%%x s3://bucket2/%%x --recursive ) #do something else here only when ALL the above commands complete Will the Start /wait have the effect of waiting until all commands complete before moving to next line after the loop? 回答1: start /wait isn't "global", it just waits for the started process to finish (maybe...

Waiting for multiple callbacks in Android

百般思念 提交于 2019-11-28 12:24:18
In Java threads, you could have some number of threads in a list, start them off, and have a main thread join one, then another, going through and waiting for all processes to complete before moving on. In other models, I'm not sure how you would do that. Take the RootTools 3.0 Command class for example. You create a Command which has three methods, commandOutput , commandFinished , commandTerminated , and while you can use a callback to do something at the end of a process, I don't know how you would wait for multiple processes (For example, going through listing of several directories and

jquery : wait until all ajax calls finish then continue [duplicate]

安稳与你 提交于 2019-11-28 11:59:02
This question already has an answer here: Wait until all jQuery Ajax requests are done? 22 answers I have some ajax calls in my document.ready() like : for (j=1; j <= 7; j++){ (function(index) { $.getJSON('my.php', {id:index}, function(data) { $.each(data, function(index2, array){ ........ }); }); })(j) } //DO NOT CONTINUE UNTIL FINISH AJAX CALLS ........ MORE JQUERY CODE How can i force it to wait and not continue until we get all the call backs from the ajax requests ? I do not like any answer at all, the best way (since Jquery 1.5+) is to use Deferred objects, those are objects to

Android - Getting volume button long clicks

一笑奈何 提交于 2019-11-28 11:48:38
问题 Can someone please show me a code example about how to get a long click (2 sec for example) on the volume up hardware key? Thanks :) EDIT The class that i want to capture the long click with is a Service. How can i do that? 回答1: If you just need to capture long clicks, this answer might be helpful: https://stackoverflow.com/a/5269673/1401257 EDIT: I have never tried to have a key listener inside a service, but with a little help from Google I found this: Volume change listener? It seems that

std::condition_variable - Wait for several threads to notify observer

安稳与你 提交于 2019-11-28 11:44:59
问题 my problem looks like this: I've got a observer which holds a std::condition_variable and a std::mutex, my worker thread objects have a pointer to the observer. Each time a worker thread finished its job it calls m_Observer->NotifyOne() which then calls the notify_one() function of the condition_variable. Now what i want to do is, start a bunch of worker threads each with a different job and different (independant) data and wait for all of them to signal (using m_Observer->NotifyOne()) the