Questions tagged [delay]

Delay refers to amount of time between two events.

A delay is simply the difference in time between two events.

This may refer to the start and stop of a single event (e.g. data processing delay) or the execution of two separate, independent events.

A delay may be manually implemented by the programmer using sleep or pause functions common in many programming languages.

In the case of computer networks, delay between sending and receiving of data packets is referred to synonymously as latency.

4215 questions
3183
votes
13 answers

How do I make a time delay?

How do I put a time delay in a Python script?
user46646
  • 153,461
  • 44
  • 78
  • 84
906
votes
35 answers

How to call a method after a delay in Android

I want to be able to call the following method after a specified delay. In objective c there was something like: [self performSelector:@selector(DoSomething) withObject:nil afterDelay:5]; Is there an equivalent of this method in android with…
aryaxt
  • 76,198
  • 92
  • 293
  • 442
388
votes
19 answers

How to create a delay in Swift?

I want to pause my app at a certain in point. In other words, I want my app to execute the code, but then at a certain point, pause for 4 seconds, and then continue on with the rest of the code. How can I do this? I am using Swift.
Schuey999
  • 4,706
  • 7
  • 21
  • 36
381
votes
1 answer

JavaScript sleep/wait before continuing

I have a JavaScript code that I need to add a sleep/wait function to. The code I am running is already in a function, eg: function myFunction(time) { alert('time starts now'); //code to make the program wait before continuing alert('time…
user2370460
  • 7,470
  • 10
  • 31
  • 46
357
votes
12 answers

Proper way to wait for one function to finish before continuing?

I have two JS functions. One calls the other. Within the calling function, I'd like to call the other, wait for that function to finish, then continue on. So, for example/pseudo code: function firstFunction(){ for(i=0;i
DA.
  • 39,848
  • 49
  • 150
  • 213
292
votes
10 answers

How to run code after some delay in Flutter?

I'd like to execute a function after a certain delay after my Widget is built. What's the idiomatic way of doing this in Flutter? What I'm trying to achieve: I'd like to start with a default FlutterLogo Widget and then change its style property…
Bradley Campbell
  • 9,298
  • 6
  • 37
  • 47
191
votes
11 answers

jQuery: Can I call delay() between addClass() and such?

Something as simple as: $("#div").addClass("error").delay(1000).removeClass("error"); doesn't seem to work. What would be the easiest alternative?
serg
  • 109,619
  • 77
  • 317
  • 330
175
votes
10 answers

jQuery: Wait/Delay 1 second without executing code

I can't get the .delay method working in jQuery: $.delay(3000); // not working $(queue).delay(3000); // not working I'm using a while loop to wait until an uncontrolled changing value is greater than or equal to another and I can't find any way to…
Nahydrin
  • 13,197
  • 12
  • 59
  • 101
174
votes
4 answers

How to add a delay for a 2 or 3 seconds

How can I add a delay to a program in C#?
Mulder
  • 1,913
  • 2
  • 13
  • 7
163
votes
4 answers

Delaying function in swift

I don't have a code to sample or anything, because I have no idea how to do it, but can someone please tell me how to delay a function with swift for a set amount of time?
CoolMAn
  • 1,851
  • 2
  • 12
  • 23
149
votes
13 answers

How to put a delay on AngularJS instant search?

I have a performance issue that I can't seem to address. I have an instant search but it's somewhat laggy, since it starts searching on each keyup(). JS: var App = angular.module('App', []); App.controller('DisplayController', function($scope,…
braincomb
  • 1,636
  • 2
  • 11
  • 11
131
votes
6 answers

How to reduce iOS AVPlayer start delay

Note, for the below question: All assets are local on the device -- no network streaming is taking place. The videos contain audio tracks. I'm working on an iOS application that requires playing video files with minimum delay to start the video…
Bernie Habermeier
  • 2,580
  • 2
  • 22
  • 20
116
votes
12 answers

Delayed function calls

Is there a nice simple method of delaying a function call whilst letting the thread continue executing? e.g. public void foo() { // Do stuff! // Delayed call to bar() after x number of ms // Do more Stuff } public void bar() { //…
TK.
  • 46,577
  • 46
  • 119
  • 147
97
votes
3 answers

How can I delay a :hover effect in CSS?

Is there a way to delay the :Hover event without using JavaScript? I know there is a way to delay animations, but I haven't seen anything on delaying the :hover event. I'm building a son-of-suckerfish like menu. I'd like to simulate what hoverIntent…
Adam Youngers
  • 6,421
  • 7
  • 38
  • 50
96
votes
15 answers

While variable is not defined - wait

I have a click event that is triggered from another place automatically for the first time. My problem is that it runs too soon, since the required variables are still being defined by Flash and web services. So right now I have: (function ($) { …
JackLeo
  • 4,579
  • 9
  • 40
  • 66
1
2 3
99 100