sleep

Sleep inside for loop in wpf

会有一股神秘感。 提交于 2019-12-24 08:28:23
问题 I have been working with WPF and threading. I would like to pause the whole screen (the application only) during a for loop. E.g. foreach (classA a in classesA) { .... .... Thread.sleep(100); } However, I found that it will sleep for long and then execute all the statement in a time. It is not what I want. I want to sleep within the execution of the for loop. That is to sleep 100ms after 1st loop, then sleep again after the 2nd loop..... I found that some article mentioned DoEvents(), but I

Python sleeps until keystroke

落花浮王杯 提交于 2019-12-24 08:22:31
问题 I'm running a long python script in the windows command line with several prints throughout my code to keep track of progress. Right before certain prints, the python code stops running and CPU Usage just drops to zero. I can "wake up" python by hitting random keys on the keyboard with the command line window as the active window. Using Task Manager, I can see that the CPU usage jumps, the print line processes ("Process took 219 seconds") and then the script gets going again. Why do I have to

Write to file not visible before close; fflush(stdout) ineffective

只愿长相守 提交于 2019-12-24 07:39:15
问题 I'm having some issues with writing to a file whilst also having a delay in a while loop. Here's a snippet: void main(int){ FILE * fp = NULL; sprintf(filename, "log%i.msg", SET_ID); fp = fopen(filename, "w+"); fprintf(fp, "File started\n"); while(1){ fprintf(fp, "%i %u %s\n", someInt, someUnsigned, someString); fflush(stdout); sleep(5); // Commenting out this line will work } fclose(fp); return 1; } Running the code gives me an output file of 0 bytes with nothing in it whilst the sleep is

Pause Between Making ImageView Invisible and Visible Android

吃可爱长大的小学妹 提交于 2019-12-24 07:27:15
问题 I'm writing an Android app, and ran into a problem while I was coding the main part of the app. I need to have an ImageView disappear for a second or two, and then reappear when tapped. The tapping part works, I use XML to make it clickable and then call a method on click. The problem is in the method that I call. I need it to: Disappear Add one to the playerscore Re-display the playerscore Reappear with a delay of a few seconds My problem is that it does not noticeably disappear no matter

Pause Between Making ImageView Invisible and Visible Android

自闭症网瘾萝莉.ら 提交于 2019-12-24 07:27:07
问题 I'm writing an Android app, and ran into a problem while I was coding the main part of the app. I need to have an ImageView disappear for a second or two, and then reappear when tapped. The tapping part works, I use XML to make it clickable and then call a method on click. The problem is in the method that I call. I need it to: Disappear Add one to the playerscore Re-display the playerscore Reappear with a delay of a few seconds My problem is that it does not noticeably disappear no matter

PHP Sleep Function (Email Throttling) Freezes Entire Server

夙愿已清 提交于 2019-12-24 02:53:04
问题 I am on a standard shared Hostgator which has a limit of 500 mails per hour. I am trying to throttle my email script to only send 1 email per 8 seconds... $query=mysql_query("SELECT email FROM users WHERE verified='1' ORDER BY balance DESC"); while($arr=mysql_fetch_array($query)){ set_time_limit(30); $mail->AddAddress($arr[0]); $mail->Send(); $mail->ClearAddresses(); echo "Sent to ".$arr[0]."<br><br>"; sleep(8); } I am using PHPMailer. The script itself works fine, it emails once every 8

PHP Sleep Function (Email Throttling) Freezes Entire Server

橙三吉。 提交于 2019-12-24 02:53:02
问题 I am on a standard shared Hostgator which has a limit of 500 mails per hour. I am trying to throttle my email script to only send 1 email per 8 seconds... $query=mysql_query("SELECT email FROM users WHERE verified='1' ORDER BY balance DESC"); while($arr=mysql_fetch_array($query)){ set_time_limit(30); $mail->AddAddress($arr[0]); $mail->Send(); $mail->ClearAddresses(); echo "Sent to ".$arr[0]."<br><br>"; sleep(8); } I am using PHPMailer. The script itself works fine, it emails once every 8

Calling a function every 1 second (precisely)

﹥>﹥吖頭↗ 提交于 2019-12-24 02:48:06
问题 I am working on a simple game simulation program in C++, there's a function called update() that updates the current state of the game, it has to be called every 1 second precisely. If I use a loop like this: while(//some condition) { update(); Sleep(1000); } Then the function will not be called every 1 second, instead, every (1 + execution time of update () ). I read about various solutions like async functions, multithreading, or calculating the function's execution time using std::chrono

PHP set_time_limit limit

随声附和 提交于 2019-12-23 21:09:48
问题 QUESTION Would it work fine if I use sleep(300); to do a whole day (24 hours) in 5-minute gaps? This means, would set_time_limit (86400); work? Then I can set my host's schedule to only be used once every 24 hours. INFO I found what I am doing now on this question and am now using it to do something every 5 minutes. It works well and is on time with even the seconds correct. (Talking about the gap between each sleep ) - it sleeps 3 times and then gets called again from my host's-schedular. I

std::this_thread::sleep_for sleeps for too long

纵饮孤独 提交于 2019-12-23 20:26:12
问题 Can anyone tell what the problem with following example is? It produces 65 instead of 300 frames per second. #define WIN32_LEAN_AND_MEAN #include <Windows.h> #include <Thread> #include <Chrono> #include <String> int main(int argc, const char* argv[]) { using namespace std::chrono_literals; constexpr unsigned short FPS_Limit = 300; std::chrono::duration<double, std::ratio<1, FPS_Limit>> FrameDelay = std::chrono::duration<double, std::ratio<1, FPS_Limit>>(1.0f); unsigned int FPS = 0; std: