FAQ Database Discussion Community


bash shell: Avoid alias to interpret $!

bash,shell,alias,wait
I have an alias created: alias my_rsync = "rsync -av ${PATH_EXCLUDE_DEV} ${PATH_SYS_DEV}/` ${PATH_SYS_SANDBOX}/ && wait $! && cd - &>/dev/null\" When is load this alias and watch it with the command 'type my_rsync' I see that $! is gone because it has been interpreted. Normally I do escape with backslash...

wait and wait on time differences?

java,multithreading,wait
I faced this question in one of the Interview. What is the difference between wait and wait on time in threads? I know wait method Causes the current thread to wait until either another thread invokes the notify() method or the notifyAll() method for this object, or a specified amount...

Shell Job Control: Track status of background with WNOHANG wait

shell,wait,background-process
What does GNU mean by this line (from here)? The shell must also check on the status of background jobs so that it can report terminated and stopped jobs to the user; this can be done by calling waitpid with the WNOHANG option. I don't understand why the shell should...

Summing up decimals returned within task

vb.net,task,wait
I'm trying to run through a list of 1-X items and process them in Tasks in order to speed up completion of processing (they make web requests that can sometimes take a short while to finish). I'm trying to sum up a decimal that is returned when the processing is...

Waiting without Sleeping? (C#)

c#,function,wait
So what I'm trying to do is start a function, then change a bool to false, wait a second and turn it to true again. However I'd like to do it without the function having to wait, how do I do this? EDIT Sadly I Can only use Visual C#...

Java: coding basic multithreading

java,multithreading,wait,notify
I'm writing a rhythm game in Java; right now I've reached the point where I'm trying to implement a metronome object. I've coded a data structure that stores 8 channels of music data into a single QuarterBeat object; these are in turn stored in groups of 64 to make 4-measure...

Wait inside loop bash

linux,bash,for-loop,while-loop,wait
I have created a loop to read through a .txt and execute another shell using each line as input. PROBLEM: I need the loop to execute the first two lines from the txt in parallel, wait for them to finish, then execute the next two lines in parallel. ATTEMPT AT...

How to create an anonymous pipe between 2 child processes and know their pids (while not using files/named pipes)?

bash,exec,wait,pid
Please note that this questions was edited after a couple of comments I received. Initially I wanted to split my goal into smaller pieces to make it simpler (and perhaps expand my knowledge on various fronts), but it seems I went too far with the simplicity :). So, here I...

Console wait until left mouse button down

c#,console,mouse,wait
I have the problem, that my console application wait at random points, until i press the left mouse button. The application is written in C#. I don't use ReadKey or something else in my application (Which even should wait for a key pressed not the mouse). Does anyone had similar...

VBA: Does 'Wait 1' wait 1 second?

vba,macros,wait
I'm currently working with some semi automated macros in VBA. I need to wait 1 second before going into the next loop. the method 'Application.wait' is not accessible due to these macros is for the AP2700 series. the loop goes like this: For i = 0 To 20 AP.S2CDsp.Analyzer.FuncFilter =...

how to decide the looping condition for wait() in Java

java,multithreading,wait,notify
I am understanding wait() in Java in regards to multithreaded, and as per the documentation, wait() should always be in a loop. I have difficult in understanding what is the condition we have to give in the loop. Typically, I have seen: synchornized(obj) { while(some_condition) { obj.wait(); } // some...

What does Protractor browser.wait return if the condition never becomes true?

promise,protractor,wait
I want to use the browser.wait function to repeatedly check if a button element is present for a certain amount of time then use the relevant callback. Below I have the code that doesn't use the wait. detailsButton.isPresent() .then(function(present){ if(!present) { callback(); } else { callback(new Error('The details button was...

How do you kill zombie process using wait()

c,linux,virtualbox,wait,zombie-process
I have this code that requires a parent to fork 3 children. How do you know (and) where to put the "wait()" statement to kill zombie processes? What is the command to view zombie processes if you have Linux virtual box? main(){ pid_t child; printf("-----------------------------------\n"); about("Parent"); printf("Now .. Forking !!\n");...

How to wait until my batch file is finished

c#,windows,batch-file,cmd,wait
I'm doing a program where I need to start cmd and there start up a batch file. The problem is that I'm using MyProcess.WaithForexit(); and I think it does not wait until the batch file processing is finished. It just waits until the cmd is closed. My code so far:...

Wait the end of a predicate Prolog

prolog,wait,predicate
I have a predicate list_moves(Move), that gives all the possible moves for a game. Then I have the following predicates : find_best_move:- nb_setval(best,0), list_moves(NewMove), nb_getval(best,OldMove), better(OldMove,NewMove). better(OldMove, NewMove):- NewMove > OldMove, nb_setval(best,NewMove), !. better(_,_). get_best_move(Move):- find_best_move, nb_getval(max,Move). I want to get only one move when I call get_best_move(Move) : the...

Swift How to wait for callback to finish before exiting function?

swift,callback,wait,apple-watch
The problem I'm having on this request is the first function syncRequest always returns nil since the function exits before the (reply, error) comes back to fill out my return dictionary. Is there a way for it to wait for the callback to return before returning out of my closure?...

How to make a browser console wait in a javascript

javascript,browser,console,wait
I'm trying to make a script that clicks on a page button, waits X seconds (for the result of the click to take place), and then continues. How can I do that? (only the wait part)...

Libgdx how to stop for loop until actor action has finished/completed

java,libgdx,wait
I have actors added to a group called cells, and in a for loop I add actions to a specific set of cells within the group. I would like it so that the next iteration of the loop is not started until the cell's action has completed. for (int i...

Who waits for a shell background process?

linux,bash,shell,process,wait
I was wondering about this question: If I type the following command in bash # sleep 100 & How come the shell knows to wait for it to end? When the shell forks itself in order to exec the sleep command, doesn't the ampersand technically means it's not going to...

Android threads can't get notify() to work properly using wait() and notify()

java,android,multithreading,wait,notify
So I am writing an Android application which will do a count down when the user presses a button. A thread runs the count down. My problem is that when I pause the application I want the thread to stop counting and then resume once the application is back. My...

How can a loop be completed by two thread? say loop from count=1 to count=4 by ist thread and count =5 to 8 by 2nd thread?

java,multithreading,wait,notify
Description of how i want the output : I want two threads Gaurav and john to complete a while loop(from 1 to 8), such that whichever thread starts ist, runs for 5 iterations(i.e. till count=5) , then go to sleep and then next thread completes the loop (run for count=6...

Run Serial inside Paralell Bash

linux,bash,while-loop,parallel-processing,wait
I have added to my explanation a bit. Conceptually, I am running a script that processes in a loop, calling shells that use the line content as an input parameter.(FYI: a kicks off an execution and b monitors that execution) I am needing 1a and 1b to run first, in...

Why can't I use notifyAll() to wake up a waiting thread?

java,multithreading,wait
I have a thread class having the following two methods: public void run() { boolean running=true; while(running) { sendImage(); } } private synchronized void sendImage() { if(!imageready.getFlag()) { try { wait(); System.out.println("woke up!"); } catch(Exception e) { System.out.println("Exception raises in ImgSender while waiting"); } } else { //send image }...

Stuck on wait() after fork()

c,fork,wait
I have looked on some topics about this, but could not solve it - I am forking twice, but when waiting for the last proc it get stuck on wait(), if i remove the wait() it moves on, but obviously it does not wait: here is the relevant code: /*Fork...

Android calling a network operation continuously?

android,multithreading,wait
In my android application I have to call a network operation after every 30 sec. Now i call the below code from the onresume of an activity. new Thread(new Runnable() { public void run() { while(true){ try { HTTPConnection httpConnection = new HTTPConnection(); httpConnection.extendSession(userId); wait(30000); } catch (InterruptedException e) {...

Program gets halted: wait() and notify()

java,multithreading,wait,synchronized,notify
I am trying to achieve this: Created two different threads, one prints odd numbers, one prints even numbers. Once one thread prints a number, it has to wait for the other thread and so on, that is one-after-other. To achieve this, i am using synchronized block along with wait() and...

Using CountDownLatch & Object.wait inside recursive block hangs

java,recursion,concurrency,wait,countdownlatch
Problem: While trying to retrieve values inside a recursive block in a phased manner, the execution gets hung. Description: CountDownLatch & Object.wait are used to achieve the phased manner access of value inside the recursive block. But, the program hangs with following output: 2 < 16 3 < 16 4...

make many process wait before the main process

batch-file,cmd,dos,wait
I have this code: Start "" robocopy F:\DATA1 D:\Backup\ Start "" robocopy G:\DATA2 D:\Backup\ Start "" robocopy H:\DATA3 D:\Backup\ Start "" D:\Backup\rename.bat How to make the rename.bat WAIT all process before execute?...

Delay() issue in C

c,winapi,wait
Even though I set different Sleep() timer for each print statement, it seems to only do the one with the highest timer. Need some help fixing this. TIA! #include <stdio.h> #include <windows.h> void gotoxy(short int x, short int y); int main() { int c = 1, d = 1, e,...

Wait until the Ajax function is done

javascript,jquery,ajax,function,wait
I have already searched on the site how to wait until the ajax function is done and i found this solution: function next() { $.when(checksign()).done(function () { if (uf == 1) { $("#usrdiv").css("display", "none"); $("#pswdiv").css("display", "inline"); } }); } function checksign() { $.ajax({ url: "checkuser.php", data: { user: u },...

How do I time out a REGQUERY command in Powershell?

powershell,registry,wait
I am trying to find a way (maybe with a job?) to timeout system jobs. It seems my regquery will normally time out after 42 seconds if the computer is not online, and the code can't reach the registry. I am looking to limit the query to around 5 seconds...

Java make GUI wait for a timer

java,multithreading,swing,timer,wait
I simply want this program to wait for a timer. All I want is for the program to pause for two seconds. I want this program to do is display "Start," wait for two seconds until the timer has finished, then display "Start, Finished Waiting, Finished." How can I make...

Wait until process in remote server finishes using Fabric

python,server,wait,fabric,remote-server
Setup I am using Fabric to kick off a process on a remote server. My local server executes a Python file that runs three functions in sequence: the 1st and 3rd in the local server and the 2nd in the remote server, as follows. local_file.py local_function_1() remote_function() local_function_2() The remote...

How to fork and create a specific number of children that perform the same task?

c,fork,wait
I need to write a C program that calls fork() a given number of times. Each child process needs to perform the same task (adding some random numbers until a given sum is reached). The parent process waits until all of the child processes have exited. I have written the...

sikuli (python) script starting at xx hour of the day, wait(“image.png”,highnumber) not working?

python,wait,exists,sikuli
first i'd like to thanks everyone who can help me i've been using a program that automated some boring features in a game i like, but it's not working anymore. the thing i want it to do is really stupid, but am not getting good results.. so 1) since i...

Wait for AJAX with iOS

ios,ajax,http,wait
I have a basic HTML page that is nothing more than a starting point for an external script (It only contains a single html, head, script tag). In this external script, I make an AJAX request to a Google API and then do some parsing with the returned data. When...

Running wait() on a Thread instance from within main() in Java

java,multithreading,wait,synchronized
I am playing around with the timed version of wait() in java.lang.Object and have observed that it acts differently in two different scenarios. Scenario1: Using the default definition of run() in Thread public static void main (String[] args) throws InterruptedException { Thread t = new Thread(); t.start(); System.out.print("X"); synchronized(t) {...

PhantomJS javascript wait until function complete

javascript,asynchronous,phantomjs,wait
I have a problem with a PhantomJS script. The script gets a JSON encoded string from a web page and does other things with it. The script: var address = address; var amount = 0; function changeAmount() { var page=require('webpage').create(); page.open (address, function(){ //parse json, set amount to something (usually...

Is there standard implementation for thread block/resume in java SE?

java,multithreading,wait
I need to block execution of a thread until resumed from another thread. So I wrote my own implementation using wait() method. Which seems to be working, but it is far from simple. Is there any ready to use solution? Preferably in java SE 6? Or do I have to...

how to make batch wait for multiple subprocesses

batch-file,cmd,wait
I have this batch file: SET WINRAR="C:\Program Files (x86)\WinRAR" start "" %WINRAR%\WinRAR.exe a -u -m5 "Group 1.rar" "Group 1" "Group 1" start "" %WINRAR%\WinRAR.exe a -u -m5 "Group 2.rar" "Group 2" "Group 2" start "" %WINRAR%\WinRAR.exe a -u -m5 "Group 3.rar" "Group 3" "Group 3" start "" "D:\" I want...

How do I run tasks in parallel and select the first result that satisfies a given condition in C#? [duplicate]

c#,.net,parallel-processing,task-parallel-library,wait
This question already has an answer here: TPL wait for task to complete with a specific return value 2 answers There are three tasks that I wish to run in parallel. I wish to examine the result of the first task that finished and do a check to decide...

Wait until Animation is finished to follow (SWIFT)

ios,swift,animation,nstimer,wait
I try to let a button "shake" before the next question of my quiz is going to load. The animation looks like var timer = NSTimer() UIView.animateWithDuration(0.1, animations: { self.IMGVIEWcat.center = CGPointMake(self.IMGVIEWcat.center.x + 2, self.IMGVIEWcat.center.y) }) UIView.animateWithDuration(0.2, animations: { self.IMGVIEWcat.center = CGPointMake(self.IMGVIEWcat.center.x - 4, self.IMGVIEWcat.center.y) }) UIView.animateWithDuration(0.3, animations: { self.IMGVIEWcat.center...

Wait Inside While Loop to Periodically Check Status

c#,.net,timer,wait
I have a simple process that sends a request to an API, waits until the API has returned a response, and then continues on with this response. I would like to avoid sleeping the main thread as this will be run as a service and I don't want to block...

make java multithread wait until input given

java,multithreading,input,wait
Im trying to make a simple code to simulate concurrent connection on a DB2 database using java. my current code looks a bit like this: class TheThread implements Runnable{ @override public void run(){ //make the database connection //need to pause here until any button pressed //execute query to the database...

Wait for an Event - Better solution than polling?

c#,events,wait
I'm working on a Problem on an existing Project. We want to read an ADC-value and normally we use there a fire-and-forget concept. We ask for the value and after the value is read an event is raised. However now I have to implement a function, which returns a value...

program stuck on wait()

c++,debugging,unix,fork,wait
I'm having an issue with a process being stuck on wait. I've been troubleshooting this issue and its the only bug i have currently for my shell program. The problem is the program should exit when the user enters "exit". However it seems if the user enters an invalid string...

Check if file written by process A is ready to be read by process B

javascript,linux,shell,wait,lsof
I have a Java script that executes a k-shell which calls a program that writes file A. Thereafter, the same Java script parses output file A. No other process read or writes file A. The problem is that file A is not always ready to be parsed in time, which...

java.lang.IllegalMonitorStateException whilst calling wait from synchronized block

java,multithreading,wait,notify
Before I move onto using Condition variables I'm trying to understand object wait principles. I wrote a little code to understand more but its not working as expected. What is supposed to happen is a Waiter class waits upon thread start. Meanwhile the Notifier class adds some elements to a...

Wait and Notify in Java threads for a given interval

java,multithreading,thread-safety,wait,notify
i am working on a usecase as below. I am new to multi threading and facing this issue with using it. I broadcast a event on network. Its received by all the listeners, and they unicast me with their information. This is received inside the call back method as below,...

How make the script wait/sleep in a simple way in unity

c#,unity3d,monodevelop,sleep,wait
How can put between the TextUI.text = .... a sleep function, for wait 3 seconds between each phrase? public Text GuessUI; public Text TextUI; [...truncated...] TextUI.text = "Welcome to Number Wizard!"; TextUI.text = ("The highest number you can pick is " + max); TextUI.text = ("The lowest number you can...

Using yield WaitForSeconds() in a function returning void

c#,unity3d,wait,void,yield-return
I have a jumpscare in my game. I am using Unity 3D. My first function is public void ScareMe(Vector3 pos) { //it does some necessary irrelevant //stuff and then it invokes another function Invoke ("Smile",.2f); } In my other function I want to make an object appear and then disappear...

Stop and Continue Looping of For Loop In Java

java,for-loop,wait
I have a project in which I am having a "for loop" iterating over an arraylist. I need to stop the iteration in between and continue again. I tried doing it by applying an "if else" condition in between but it didn't work. I have an arraylist of size 2500...