delay

How to use nanosleep for sleeping random amounts of time?

China☆狼群 提交于 2019-12-02 08:25:30
问题 Im trying to use the function nanosleep to make my process sleep for a random amount of time between 1/10th of a second? im using srand() to seed my random number generator, with the process id, that is, im calling: srand(getpid()); then using struct timespec delay; delay.tv_sec = 0; delay.tv_nsec = rand(); nanosleep(&delay, NULL); How can i make sure im sleeping for 0..1/10th of a second? 回答1: I'd say you just need 100000000ULL * rand() / RAND_MAX nanoseconds, this is at most 0.1s and at

I need help figuring out why my flip function only fires once and them seems to unbind. Any ideas?

情到浓时终转凉″ 提交于 2019-12-02 08:09:01
I'm using 3 plugins here flip, delayed, and fancybox. I have it written so when you click the flip event fires, then delayed, then fancybox after the delay. I can't figure out why the flip is only working once but fancybox keeps working on subsequent clicks. Any tips would be appreciated. Thanks. <script type="text/javascript"> jQuery.noConflict(); // First Home Page Popout Box jQuery(document).ready(function() { jQuery('#card-processing-link').live('click', function() { jQuery('#card-processing-box').flip({ 'direction' : 'lr', speed : '300' }); }); //Fancybox popout event jQuery('.card

How can I automatically send an email with delay from an Outlook inbox usign VBA?

烂漫一生 提交于 2019-12-02 07:54:16
I'm new in the ways of VBA and I want to create a rule (script) that can automatically forward an email received in my Outlook inbox with a specified delay? Can you please give me some instructions on how can I achieve this? I tried: Public Declare Sub Sleep Lib "kernel32" (ByVal dwMiliseconds As Long) Sub send(Item As Outlook.MailItem) Set fwd = Item.Forward fwd.Recipients.Add "mail@email.com" Sleep (10000) fwd.send End Sub Also tried: Sub WasteTime(Finish As Long) Dim NowTick As Long Dim EndTick As Long EndTick = GetTickCount + (Finish * 1000) Do NowTick = GetTickCount DoEvents Loop Until

javascript ajax setinterval delay

谁说胖子不能爱 提交于 2019-12-02 07:50:12
How can I execute this function immediately, then start the setInterval timer? Here is my js. $(document).ready(function(){ var callAjax = function(){ $.ajax({ method:'get', url:'apinvs.php', dataType:'html', success:function(data){ $("#main").html(data); } }); } setInterval(callAjax,2500); }); It's executing the function after 2.5 seconds. It leaves the div blank until 2.5 seconds pass, which is what I don't want to happen. :( I found a Stackoverflow question here but I'm not sure how to apply it with my code (it's using document ready). Thanks for any assistance. Change setInterval(callAjax

Pause without Delay() arduino

别等时光非礼了梦想. 提交于 2019-12-02 07:46:16
I am using an arduino uno, logic level converter, adafruit Bicolor LED Matrix, a Raspberry pi, and a button but am having some issues. My goal is that when the button is pushed on the pi it sends a signal to the arduino Uno which will change the animation on the LED backpack. The issue is that the button must be held down right when the loop restarts and if you click it any other time it wont work, I think this is because I am using delay() which pauses everything. Is there any way to pause without using delay()? I have heard of using Millis() but I am new to Arduino's and im not sure how I

android substuting the click with a timer

我是研究僧i 提交于 2019-12-02 07:07:12
I found this example and i have a small question: How can I remove the on click to a timer or a delay where it displays the first image and waits a couple of seconds then moves to the next image? http://mobile.dzone.com/news/displaying-images-sd-card?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed%3A+javalobby%2Ffrontpage+%28Javalobby+%2F+Java+Zone%29 Thank you. package blog.android.sdcard; import android.app.Activity; import android.content.Context; import android.content.Intent; import android.database.Cursor; import android.net.Uri; import android.os.Bundle; import android.provider

When the page is loaded,how to make six functions executed by each otherr?

空扰寡人 提交于 2019-12-02 06:58:49
When the page is loaded , in a big div, there are six different elements and there are six different functions for the elements.I want to make the functions execute by each other after a sure time for example 1000ms.But the six functions are not bind to one elements ,they are binded to six different elements. For example, when the page is loaded,I want addClass "line1" to element "#linear1", after 1000ms, removeClass ".line1" from element "#linear1", and immediately, addClass "line2" to element "#linear2", after 1000ms, removeClass ".line2" from element "#linear2", and immediately, addClass

How to use nanosleep for sleeping random amounts of time?

烈酒焚心 提交于 2019-12-02 05:55:28
Im trying to use the function nanosleep to make my process sleep for a random amount of time between 1/10th of a second? im using srand() to seed my random number generator, with the process id, that is, im calling: srand(getpid()); then using struct timespec delay; delay.tv_sec = 0; delay.tv_nsec = rand(); nanosleep(&delay, NULL); How can i make sure im sleeping for 0..1/10th of a second? I'd say you just need 100000000ULL * rand() / RAND_MAX nanoseconds, this is at most 0.1s and at least 0s. Alternatively, try usleep() with argument 100000ULL * rand() / RAND_MAX . (I think usleep requires

JavaScript: setTimeout doesn't pause the loop

本秂侑毒 提交于 2019-12-02 05:21:45
I need to make some delays in my loop, every time after some amount of data (after a few cycles/iterations through my loop) is sent to the server. Sending data and receiving respond from the server works fine, but requested delays in loop still don't work. Thanks a lot for your help. EDIT: Code was changed, please check the third answer (mine). <!DOCTYPE html> <html> <body> <h2>AJAX</h2> <button type="button" onclick="loadDoc()">Request data</button> <p id="demo"></p> <script> function loadDoc() { var xhttp = []; var code = [ "WOICEL0Q9P", "ZJTS4GYJEJ", "HJPMQOCX31", "MP26N0BH01", "7TJNYZIRJR"

Fade In String Characters with JQuery?

随声附和 提交于 2019-12-02 03:43:41
Here is my code. For some reason the entire String fades in at one time instead of each individual character. My console.log shows the characters are being executed one by one. Why is the entire string fading in at one time? Shouldn't the statement within the for loop execute for each character? <!DOCTYPE html> <head> <script src="jquery.js" type="text/javascript" charset="utf-8"></script> <script> $(function() { string = " David"; for(i = 0; i < string.length; i++) { $('#fadeIn').append(string[i]).delay(1000).hide().fadeIn(1000); console.log(string[i]); } }); </script> </head> <body> <div id=