wait

Making a thread wait two seconds before continuing in C# WPF

て烟熏妆下的殇ゞ 提交于 2019-12-24 12:39:10
问题 I'm having trouble making a thread wait for two seconds without blocking the GUI. The most simple wait method I know is Thread.Sleep(2000); . If you can use some examples of timers or others that I'm not aware of, please do because I'm not too familiar with the ways of coding. private void run_program_Click(object sender, RoutedEventArgs e) { if (comboBox1.Text == "Drive forwards and back") { stop.IsEnabled = true; EngineA(90); //Makes EngineA drive at 90% power EngineB(90); //Makes EngineB

how to make delphi wait 30sec then continue

此生再无相见时 提交于 2019-12-24 11:44:29
问题 I am trying to make an infinite loop but I want the loop to run every 30 seconds. The loop will start. A bunch of if statements take place and some information will be changed. The loop must then pause for 30 seconds and then the loop will start again. This must continue forever. I am looking for a way to pause the loop for 30 seconds and then continue. Any good advice will be appreciated. EDIT #1 The program shows "special" information based on date and time: As the time changes the

java.util.concurrent.locks.Condition awaitUninterruptibly()

走远了吗. 提交于 2019-12-24 10:49:32
问题 While I am reading java.util.concurrent.locks.Condition API documentation, I see that: When waiting upon a Condition, a "spurious wakeup" is permitted to occur, in general, as a concession to the underlying platform semantics. This has little practical impact on most application programs as a Condition should always be waited upon in a loop, testing the state predicate that is being waited for. An implementation is free to remove the possibility of spurious wakeups but it is recommended that

Waiting for a file to load (onload JavaScript)

那年仲夏 提交于 2019-12-24 10:00:02
问题 I want to read a text from a file and return it in a function. So here's the important part of my code: function getFileRequest(id, contentType, callback) { var val = "x"; if (window.File && window.FileReader && window.FileList && window.Blob) { var element = document.getElementById(id); var file = element.files[0]; if(file != null) { if(file.type.match("text/xml")){ var r; r = new FileReader(); r.onload = function (e) { val = e.target.result; } r.readAsText(file); } else alert("Wrong file

Javascript calculate image size, after image load

自古美人都是妖i 提交于 2019-12-24 09:58:32
问题 function loader(img) { var imgH = img.height; var imgW = img.width; console.log(imgH, imgW); }; img = new Image(); img.src ='../images/pic1.jpeg'; img.onLoad = loader(img); So, It is exepeted, that I'll get image's size, but I got "0 0" in console. And size of image is 500X700. What's wrong with this code? 回答1: This makes no sense: img.onLoad = loader(img); you want to pass the actual function to the event: img.onload = loader; and use this instead of img within the function. Also you need to

Is there a need to add waits in between of the script in webdriver

早过忘川 提交于 2019-12-24 09:47:51
问题 I am writing my first webdriver script in java, the script is working fine but it's very fast. For eg :- I have textboxes and dropdown elements in my hmtl page and i wrote the script for sending keys and selecting values from the elements but when I execute the script it's very fast is there any need to give implicit waits after every step ? Is it worth ? Or what else is the solution so that the script runs in a smooth way that every step is visible properly. Below is my code :- public static

Is there a need to add waits in between of the script in webdriver

瘦欲@ 提交于 2019-12-24 09:42:59
问题 I am writing my first webdriver script in java, the script is working fine but it's very fast. For eg :- I have textboxes and dropdown elements in my hmtl page and i wrote the script for sending keys and selecting values from the elements but when I execute the script it's very fast is there any need to give implicit waits after every step ? Is it worth ? Or what else is the solution so that the script runs in a smooth way that every step is visible properly. Below is my code :- public static

Wait for finished download file in selenium and c#

戏子无情 提交于 2019-12-24 06:27:16
问题 I have some problem. I download a file after click icon on web application. My next step is carried out faster than the record file. I watn to use some watit, but i have any idea how ? Somebody know how write that wait ? 回答1: I use the following script ( filename should be passed in). The first part waits till the file appears on disk (fine for chrome) The second part waits till it stops changing (and starts to have some content) var downloadsPath = Environment.GetEnvironmentVariable(

Making turtles wait x number of ticks

橙三吉。 提交于 2019-12-23 17:23:15
问题 Part of what I am trying to do is make a breed of turtles move around, but when one reaches its destination that turtle waits for a certain number of ticks before continuing ? Also is it possible to make turtles wait for different number of ticks depending upon their destination ( different patch colors). Is it a case of making a turtle breed or global variable to count the number of ticks? The hopefully relevant code is below. 回答1: You are right, this can be done by making the turtles count

Is it possible to wait until a toast has finished to resume the method?

女生的网名这么多〃 提交于 2019-12-23 16:51:34
问题 In one of my methods, I have a toast that appears if the user gives the correct input. However, I do not want the next image to display until the toast has finished. If I use Thread.sleep(3000) if does not allow the toast to show as the UI activity is asleep. An example of what I am trying to do: public void correction(){ if(correctionBoolean == true){ Toast.makeText(this, "Correct!", Toast.LENGTH_SHORT).show(); if(Toast.time == finished){ NextImage();} } 回答1: I don't believe there would be