wait

Thread interrupt: will it cancel oncoming wait() call?

别等时光非礼了梦想. 提交于 2019-12-03 12:04:10
问题 I have a thread which has an incoming job queue (a LinkedList containing job descriptions). The thread blocks with wait() on the queue when there's no job to work on. An external job dispatcher object awakes it with notify() when it places new jobs on the queue. At shutdown of my program i call interrupt() on the Thread. This raises InterruptedException when the Thread awaits for jobs in wait() . My question is: what will happen if i interrupt the Thread while it's not blocking but doing some

How to force a program to wait until an HTTP request is finished in JavaScript?

隐身守侯 提交于 2019-12-03 11:19:29
问题 Is there a way in JavaScript to send an HTTP request to an HTTP server and wait until the server responds with a reply? I want my program to wait until the server replies and not to execute any other command that is after this request. If the HTTP server is down I want the HTTP request to be repeated after a timeout until the server replies, and then the execution of the program can continue normally. Any ideas? Thank you in advance, Thanasis 回答1: There is a 3rd parameter to XmlHttpRequest 's

Temporarily bypassing implicit waits with WebDriver

China☆狼群 提交于 2019-12-03 11:00:39
问题 When using implicit waits, as advised here , I still sometimes want to assert the immediate invisibility or non-existence of elements. In other words, I know some elements should be hidden, and want my tests make that assertion fast , without spending several seconds because of the (otherwise useful) implicit wait. One thing I tried was a helper method like this: // NB: doesn't seem to do what I want private boolean isElementHiddenNow(String id) { WebDriverWait zeroWait = new WebDriverWait

Javascript: Non-blocking way to wait until a condition is true

耗尽温柔 提交于 2019-12-03 06:46:32
I have several ASP.NET UpdatePanels, each with an AsyncPostBackTrigger tied to the same button's serverside click event. Since only one UpdatePanel can be doing its thing at a time, I use .get_isInAsyncPostBack() of the PageRequestManager to prevent a user from being able to access another part of the page until the async postback is complete. Another part of this page needs to dynamically update multiple update panels consecutively. Since the update panels use async triggers, calling __doPostBack("<%=ButtonName.ClientID %>", 'PanelId'); fires asynchonously. Because of this, it will quickly

Qt5: How to wait for a signal in a thread?

五迷三道 提交于 2019-12-03 05:58:55
问题 Probably the title question is not very explicit. I am using Qt5 on Windows7. In a thread (QThread) at some point, in the "process()" function/method, I must wait for the "encrypted()" SIGNAL belonging to a QSslSocket I am using in this thread. Also I suppose I should use a QTimer and wait for a "timeout()" SIGNAL in order to avoid getting blocked in an infinite loop... What I have now is: // start processing data void Worker::process() { status = 0; connect(sslSocket, SIGNAL(encrypted()),

How can I make my Docker compose “wait-for-it” script invoke the original container ENTRYPOINT or CMD?

霸气de小男生 提交于 2019-12-03 04:45:00
According to Controlling startup order in Compose , one can control the order in which Docker Compose starts containers by using a " wait-for-it " script. Script wait-for-it.sh expects both a host:port argument as well as the command that the script should execute when the port is available. The documentation recommends that Docker Compose invoke this script using the entrypoint: option. However, if one uses this option, the container will no longer run its default ENTRYPOINT or CMD because entrypoint: overrides the default. How might one provide this default command to wait-for-it.sh so that

Using wait in AsyncTask

我怕爱的太早我们不能终老 提交于 2019-12-03 04:43:32
问题 When using a wait in an AsyncTask , I get ERROR/AndroidRuntime(24230): Caused by: java.lang.IllegalMonitorStateException: object not locked by thread before wait() Is it possible to use an Asynctask just for waiting? How? Thanks class WaitSplash extends AsyncTask<Void, Void, Void> { protected Void doInBackground(Void... params) { try { wait(MIN_SPLASH_DURATION); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } return null; } protected void

What does wait() do on Unix?

浪子不回头ぞ 提交于 2019-12-03 03:23:33
I was reading about the wait() function in a Unix systems book. The book contains a program which has wait(NULL) in it. I don't understand what that means. In other program there was while(wait(NULL)>0) ...which also made me scratch my head. Can anybody explain what the function above is doing? man wait(2) All of these system calls are used to wait for state changes in a child of the calling process, and obtain information about the child whose state has changed. A state change is considered to be: the child terminated; the child was stopped by a signal; or the child was resumed by a signal So

await Task.Delay() vs. Task.Delay().Wait()

谁都会走 提交于 2019-12-03 02:59:16
问题 In C# I have the following two simple examples: [Test] public void TestWait() { var t = Task.Factory.StartNew(() => { Console.WriteLine("Start"); Task.Delay(5000).Wait(); Console.WriteLine("Done"); }); t.Wait(); Console.WriteLine("All done"); } [Test] public void TestAwait() { var t = Task.Factory.StartNew(async () => { Console.WriteLine("Start"); await Task.Delay(5000); Console.WriteLine("Done"); }); t.Wait(); Console.WriteLine("All done"); } The first example creates a task that prints

How to force a program to wait until an HTTP request is finished in JavaScript?

旧巷老猫 提交于 2019-12-03 02:49:48
Is there a way in JavaScript to send an HTTP request to an HTTP server and wait until the server responds with a reply? I want my program to wait until the server replies and not to execute any other command that is after this request. If the HTTP server is down I want the HTTP request to be repeated after a timeout until the server replies, and then the execution of the program can continue normally. Any ideas? Thank you in advance, Thanasis There is a 3rd parameter to XmlHttpRequest 's open() , which aims to indicate that you want the request to by asynchronous (and so handle the response