delay

give a delay of few seconds without using threads

一曲冷凌霜 提交于 2019-12-30 03:23:09
问题 How can I give a delay of few seconds without using threads.some function that I can call anywhere for giving delay. Android built-in function is highly preferred. Thanks 回答1: Use a Handler, and send either a simple message or a Runnable to it using a method such as postDelayed(). For example, define a Handler object to receive messages and Runnables: private Handler mHandler = new Handler(); Define a Runnable: private Runnable mUpdateTimeTask = new Runnable() { public void run() { // Do some

Delay execution 1 second

强颜欢笑 提交于 2019-12-29 08:42:05
问题 So I am trying to program a simple tick-based game. I write in C++ on a linux machine. The code below illustrates what I'm trying to accomplish. for (unsigned int i = 0; i < 40; ++i) { functioncall(); sleep(1000); // wait 1 second for the next function call } Well, this doesn't work. It seems that it sleeps for 40 seconds, then prints out whatever the result is from the function call. I also tried creating a new function called delay, and it looked like this: void delay(int seconds) { time_t

Delay execution 1 second

倾然丶 夕夏残阳落幕 提交于 2019-12-29 08:42:04
问题 So I am trying to program a simple tick-based game. I write in C++ on a linux machine. The code below illustrates what I'm trying to accomplish. for (unsigned int i = 0; i < 40; ++i) { functioncall(); sleep(1000); // wait 1 second for the next function call } Well, this doesn't work. It seems that it sleeps for 40 seconds, then prints out whatever the result is from the function call. I also tried creating a new function called delay, and it looked like this: void delay(int seconds) { time_t

How do I make this java for loop pause for 1/2 a second between each iteration?

人走茶凉 提交于 2019-12-29 02:09:12
问题 private class MultipleGensListener implements ActionListener { public void actionPerformed(ActionEvent e) { for(int i = 0; i < 25; i++) { game.runSimulationOneGen(); changeGrid(); } } } //this is the loop. The changeGrid method displays a game grid on a GUI but // only the 25th iteration is visible on screen. I would like each one to be // visible for about a half a second before the loop continues. // I have seen some questions answered on here that are very close to what I'm asking, // but

How to delay jquery animation?

青春壹個敷衍的年華 提交于 2019-12-28 03:54:46
问题 I can't seem to delay the showing of a div. I want to delay the animation by about 20 seconds is this possible??? $("#microcharcounter").delay(10000).show(); 回答1: Try this: $("#microcharcounter").delay(10000).show(0); or this: $("#microcharcounter").delay(10000).queue(function(n) { $(this).show(); n(); }); The reason for this is that .delay() will only delay items in an animation queue. So you can make .show() a short animation by adding a duration of '0', or add it to the queue with .queue()

How can I stop PHP sleep() affecting my whole PHP code?

本小妞迷上赌 提交于 2019-12-28 03:04:07
问题 So, on my arcade, howlingdoggames.com. I have a points system that gives you a point every time you visit a page with a game on, now, to reduce abuse of this, I would like to make some sort of delay, so its only awarded after 45 seconds. Here's what i've tried. ... if ($_SESSION['lastgame'] != $gameid);{ sleep(45); $points = $points + $game_points; $_SESSION['lastgame'] = $gameid; } ... But, this just seems to halt my whole website for 45 seconds, because this is in the index.php file, as

How to set 1 second time delay at assembly language 8086

主宰稳场 提交于 2019-12-28 03:03:25
问题 My problem is that I have written a code that is supposed to output a result into a set of LEDs connected to the parallel port. When I ran the code it pretty much did nothing. My instructor told me that the code ran too fast that my eyes did not see what happened. I have found that there are a couple of ways to do a time delay, I have tried to loop the NOP but I think I cannot really determine what is going on. Is there any better way? I have here a part of the code where I have to add a time

RxJava delay for each item of list emitted

廉价感情. 提交于 2019-12-28 01:50:34
问题 I'm struggling to implement something I assumed would be fairly simple in Rx. I have a list of items, and I want to have each item emitted with a delay. It seems the Rx delay() operator just shifts the emission of all items by the specified delay, not each individual item. Here's some testing code. It groups items in a list. Each group should then have a delay applied before being emitted. Observable.range(1, 5) .groupBy(n -> n % 5) .flatMap(g -> g.toList()) .delay(50, TimeUnit.MILLISECONDS)

Very strange issue in Swift code. Delay to make operations

◇◆丶佛笑我妖孽 提交于 2019-12-25 17:45:41
问题 I've a very strange issue I could't solve. I'm developing an iOS app using swift. In a class (class A), I call another class (class B) for connecting to a server. This server return a json, I pass the result to class A but I get an important delay for the operation I wish. Here's the code of class A: func loginUser () { //check for data if txt_mail!.text == "" || txt_password!.text == ""{ var alertView = UIAlertView(title: "Error", message: "no data", delegate: nil, cancelButtonTitle: "OK")

jQuery slideshow with different delay times

一个人想着一个人 提交于 2019-12-25 15:17:33
问题 I have used Innerfade and Cycle, but I have several divs I need to fade in, pause and fade out, but I want to pause at different rates for different slides because some will have more content than others. I didn't see how I could accomplish this with Innerfade or Cycle. I tried this, but all of the events fire at once. <div id="slides"> <div id="slide1" style="display:none;">Content1</div> <div id="slide2" style="display:none;">Content2</div> <div id="slide3" style="display:none;">Content3<