wait

Wait for a user event [duplicate]

不羁岁月 提交于 2019-11-29 15:21:54
This question already has an answer here: How do I return the response from an asynchronous call? 36 answers I'm developing a javascript class (with jQuery) to create custom popup, but I can not figure out how to "pause" the script to wait for user response (click on the OK button or cancel) the class is like this: function Popup() { } Popup.Show = function(text) { var _response; /* code to draw the popup elements*/ $("#button-ok").on("click",function() { _response = "ok!" } return _response } if, for example, use it in an alert, the method always return "undefined", because it does not wait

Android: Wait() the main thread while a dialog gets input in a separate Thread

丶灬走出姿态 提交于 2019-11-29 14:32:40
I'm writing an activity in Android where the user modifies an SQL Database. The UI consists of an EditText where the user enters the name, and a Seekbar where the user enters how attractive the person is. Underneath there are a bunch of buttons: add, edit, view, delete. When the user clicks on the "Edit" button, an input dialog is displayed asking the user to input the record number. Once that is done, that record is loaded. The problem I was having was that the inputdialog would be displayed and while the user entering the record no, the rest of the edit method would carry on so that by the

Synchronous startActivityForResult - Waiting for Activity to Complete

你。 提交于 2019-11-29 13:48:18
I have an application where I am launching a new Activity, and need to have the result of the activity before proceeding. I realize that startActivityForResult is asynchronous / non-blocking, and that I can get the result of the activity in the onActivityResult callback. So I guess what I'm looking for is the best way to wait for the activity to return... Something like this perhaps? Or is there a better way? Activity Launcher Function: public String ActivityLauncher() { //Set up Intent startActivityForResult(intent, 1); while (mIsActivityDone == false) { Thread.Sleep(250); } //Continue with

Make JavaFX wait and continue with code

最后都变了- 提交于 2019-11-29 13:24:12
问题 Basically I am trying to make a short effect using JavaFX. I have the shape of a heart (added together from two circles and a polygon) that I can vary in size using the double value p . "Standart Size" would be p = 1.0; . I am trying to add a pumping effect to the heart. I have the method pumpOnce() : public void pumpOnce(){ p = p + 1; initHeart(); //Here goes what ever it takes to make stuff working!! p = p - 1; initHeart(); } initHeart() draws the heart based on p . I have found out that

Wait for and/or kill process grandchildren produced by fork

徘徊边缘 提交于 2019-11-29 12:45:06
I fork() into process X and Y, afterwards Y forks() again into itself and process Z multiple times. Now process Y is some kind of "listener" and I would like X to be the deleter. The Z processes perform the actual actions. Z processes are grandchildren of X. With a FIFO and some signaling, X has produced a list of all pids of the Z processes. The problem now is that I would like to delete Z process zombies with X (going through the list of pids). I've tried it with waitpid() , but of course that doesn't work (it only does for direct children). But I've read about the possibility of making an

jQuery - Wait till end of SlideUp()

纵然是瞬间 提交于 2019-11-29 09:07:38
How can I wait till the end of the jQuery function slideUp() before continuing the script? <script type="text/javascript"> $(document).ready(function() { $("div[class=item]").click(function() { var id = $(this).attr("id"); $("#content").slideUp(); switch(id) { // Applications case "rampro": $("#content").css("text-align", "left"); $("#content").load("inc/pages/rampro.html"); $("#content").slideDown(); break case "diskman": $("#content").css("text-align", "left"); $("#content").load("inc/pages/diskman.html"); break case "iconmap": $("#content").css("text-align", "left"); $("#content").load("inc

How can I delay a MouseOver in Java?

南楼画角 提交于 2019-11-29 08:52:22
I've got a short question and I hope somebody can help me. Please look at the following code snippet: public void mouseEntered(MouseEvent e){ //wait 2 seconds. //if no other mouseEntered-event occurs, execute the following line //otherwise restart, counting the 2 seconds. foo(); } Can somebody help me with that problem? I want to realize a behavior like an ToolTip: you enter a region with your mouse. If your mouse stays in that position, do something. Start a Timer with a delay of 2 seconds in your mouseEntered() method that calls whatever it is you want to do. Set up a new handler (

Waiting for all the threads to finish before shutting down the Executors

…衆ロ難τιáo~ 提交于 2019-11-29 08:11:26
Here is my code snippet. ExecutorService executor = Executors.newFixedThreadPool(ThreadPoolSize); while(conditionTrue) { ClassImplementingRunnable c = new ClassImplementingRunnable(); executor.submit(c); } Now after this is do executor.shutdown(); What i want to achieve here is that i want to wait for all the threads in the threadpool to have finished the execution and then i want to shutdown the executor. But i guess this is not what is happening here. The main thread seems to be executing shutdown and it just shuts down everything. Before when my threadpool size was 2, i did the following

Adding a wait-for-element while performing a SplashRequest in python Scrapy

走远了吗. 提交于 2019-11-29 07:52:34
问题 I am trying to scrape a few dynamic websites using Splash for Scrapy in python. However, I see that Splash fails to wait for the complete page to load in certain cases. A brute force way to tackle this problem was to add a large wait time (eg. 5 seconds in the below snippet). However, this is extremely inefficient and still fails to load certain data (sometimes it take longer than 5 seconds to load the content). Is there some sort of a wait-for-element condition that can be put through these

Checking the status of a child process in C++

主宰稳场 提交于 2019-11-29 07:17:23
问题 I have a program that uses fork() to create a child process. I have seen various examples that use wait() to wait for the child process to end before closing, but I am wondering what I can do to simply check if the file process is still running. I basically have an infinite loop and I want to do something like: if(child process has ended) break; How could I go about doing this? 回答1: Use waitpid() with the WNOHANG option. int status; pid_t result = waitpid(ChildPID, &status, WNOHANG); if