problem about wait-Collection of common programming errors
mimoralea
c process fork parent-child wait
I’m starting to learn some C and while studying the fork, wait functions I got to a unexpected output. At least for me. Is there any way to create only 2 child processes from the parent? Here my code:#include <sys/types.h> #include <stdio.h> #include <unistd.h> #include <sys/wait.h>int main () {/* Create the pipe */int fd [2];pipe(fd);pid_t pid;pid_t pidb;pid = fork ();pidb = fork ();if (pid < 0){printf (“Fork Failed\n”);return -1;}else if (pid == 0){//printf(“I’m the
CAbbott
asp.net repeater wait data-binding
i want to do the same think us mysql sorting on colone, i have the table colone title and an imagebutton next, when i click on the imagebutton i databind myrepeater and i want to change the imageurl of the imagebutton after that, i’m doing like that protected void UserRepeater_ItemCommand(object source, RepeaterCommandEventArgs e) {switch (e.CommandName){case “country”:break;default:string criteres = e.CommandName;ImageButton image = (ImageButton)UserRepeater.Controls[0].Controls[0].FindControl(
Henning Makholm
java join deadlock wait notify
Given the following Java code:public class Test {static private class MyThread extends Thread {private boolean mustShutdown = false;@Overridepublic synchronized void run() {// loop and do nothing, just wait until we must shut downwhile (!mustShutdown) {try {wait();} catch (InterruptedException e) {System.out.println(“Exception on wait()”);}}}public synchronized void shutdown() throws InterruptedException {// set flag for termination, notify the thread and wait for it to diemustShutdown = true;no
Zizo47
c# loops button wait boolean
I want to make the program wait for a button to be pressed before it continues, I tried creating a while loop and having it loop until the button is clicked and sets a bool to true for the while loop to end, this made it crashwhile (!Redpress){//I’d like the wait here}Redpress = false;It doesn’t matter whether or not the while is there, as long as the program waits for the button press before setting “Redpress” to false… Any Ideas?
Andrew Thompson
java swing event-handling wait event-dispatch-thread
What is the proper way to implement the following code? I want to get the takeTurn() method to wait for the player to click on a button on the grid corresponding to the piece he wants to select. (Button objects have instance variables int col, row and extend JButton.)int selectedCol, selectedRow;void takeTurn() {System.out.print(name + “‘s turn. “);// Get player to select a pieceselectedCol = -1;selectedRow = -1;while (selectedCol == -1 && selectedRow == -1) {try {wait(500);} catch (Inte
Lukasz Lew
linux posix exec fork wait
I do the usual fork + exec combination:int sockets [2]; socketpair (AF_LOCAL, SOCK_STREAM, 0, sockets); int pid = fork ();if (pid == 0) {// childdup2 (sockets[0], STDIN_FILENO);dup2 (sockets[0], STDOUT_FILENO);execvp (argv[0], argv);_exit (123); } // parentclose (sockets[0]); // TODO wait and see if child crashesIs it possible to wait until child crashes or begins waiting on read(…)?
DMA57361
windows-7 windows boot wait
Possible Duplicate:Stop Windows 7 from installing some updates which aren’t working?Prevent Windows 7 from installing a “critical” updates that crashes the system.Windows Update Failure Has anyone experienced something like that? Could’t dfind anything about that behaviour in the MS Knowledge Base. This drives me crazy 😉
MOHAMED
c fork pipe wait
I have the following programint external_apply(char *type) {int pfds[2];if (pipe(pfds) < 0)return -1;if ((pid = fork()) == -1)goto error;if (pid == 0) {/* child */const char *argv[8];int i = 0;argv[i++] = “/bin/sh”;argv[i++] = “script_file.sh”;argv[i++] = “apply”;close(pfds[0]);dup2(pfds[1], 1);close(pfds[1]);execvp(argv[0], (char **) argv);exit(ESRCH);} else if (pid < 0)goto error;/* parent */close(pfds[1]);int status;while (wait(&status) != pid) {printf(“waiting for child to exit”);}
Jim
java android exception sleep wait
I’ve got a pretty simple app I’m trying to make. What I want to do is have an app that can send multiple texts to 1 or more recipients. I have accomplished this, but it doesn’t seem to send the full number of texts.I assume the problem is that the texts are being sent to rapidly. I’m trying to just make the program wait a second, but when I just type in “Thread.sleep(1000);” I get an error saying there is an unhandled exception in Eclipse. Is there a way around this? Do I really need to do a try
pprakash
selenium webdriver wait
I’m executing the following codeimport selenium from selenium import webdriver driver = webdriver.Remote(command_executor=”http://selenium.server.com:4444/wd/hub”, desired_capabilities=”webdriver.DesiredCapabilities.FIREFOX”) driver.implicitly_wait(60) driver.get(‘http://www.google.com’)But it’s causing an exception7610 [SocketListener0-1] INFO org.openqa.jetty.jetty.context./wd – WebDriver remote server: Fatal, unhandled exception: /session:java.lang.ClassCastException:java.lang.String cannot b
nacho22
android multithreading wait notify
I’m programming an application that has to start, pause and restart a thread deppending on the buttons the user press [Start and Abort]. To control the thread I create a Service to work with the Activity, like follows:Code of the Activitypublic class SoundLocalizer extends Activity {@Overridepublic void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);if(D) Log.e(TAG, ” ON CREATE “);// Set up the window layoutsetContentView(R.layout.main);}public void onStart() {super.onSt
Scott Jones
javascript jquery wait module-pattern
I have written a custom js module that basically sends messages and needs to wait for a response in order to continue:var manageBooking = (function (jQ) {//decalre private variables var domain, msgRecieved, msgResponse, validationValue; //decalre private functions var sendMessage, wait;// A private variables domain = document.domain; msgRecieved = false; msgResponse = null;wait = function(timeOutStep){var w;console.log(‘msgRecieved’, msgRecieved);if (msgRecieved === true) {clearTimeout(w);return
Pierre
jquery asynchronous getjson wait
I’ve got a successful call going out to a coldfusion database controller using jQuery’s getJSON method. The returned information comes back in the format:{“COLUMNS”: [“PRODUCT_HIERARCHY”, “WEBPRODLINE”, “POSITION”, “FEATURES”, “BENEFITS”, “LINKS”, “VIDEOS”, “IMAGE_CUTAWAY”, “MARKEDASNEW”],”DATA”: [[“23456689”, “ProdName1”, “A Feature 1”, “A Benefit 1”, “url”, “vid_url”, “img_name”, “N”],[“234566891”, “ProdName2”, “A Feature 2”, “A Benefit 2”, “url”, “vid_url”, “img_name”, “N”]] }I now want to st
Seeb
ruby timeout wait watir-webdriver rescue
I have always learned that good coding means: do not repeat yourself. But these days I keep repeating myself, in an attempt to let my scrapers handle timeout errors.For every link or button that I click, i add a rescue Exception => e and refresh the page. For example browser.link(:xpath, “//tr[@class=’pager’][1]/td/a”).when_present.clickturns intobeginbrowser.link(:xpath, “//tr[@class=’pager’][1]/td/a”).wait_until_presentbrowser.link(:xpath, “//tr[@class=’pager’][1]/td/a”).click rescue Exception
anilCSE
angularjs wait angularjs-service
I am using some data which is from a RESTful service in multiple pages. So I am using angular factories for that. So, I required to get the data once from the server, and everytime I am getting the data with that defined service. Just like a global variables. Here is the sample:var myApp = angular.module(‘myservices’, []);myApp.factory(‘myService’, function($http) {$http({method:”GET”, url:”/my/url”}).success(function(result){return result;}); });In my controller I am using this service as:func
Jonathan Leffler
c process fork wait forking
I am trying to write a program where a parent process would fork n children(node_number of children) and where the children have to carry out a specific task which is the same for every child. After placing a couple of printf’s in my code I realized that there is an error in the for loop in the child processes which is that the for does not terminate at the right place, for example if the code reads, for(p=0;p<=10; p++) the printf shows that the process does not count up to more than p=6!I am
ayelder
c multithreading status wait
I am wondering if it is possible to check the status of a thread, which could possibly be in a waitable state but doesn’t have to be and if it is in a waitable state I would like to leave it in that state. Basically, how can I check the status of a thread without changing its (waitable) state.By waitable, I mean if I called wait(pid) it would return properly and not hang.Let me also add that I am tracing a multithreaded program, therefore I cannot change the code of it. Also, I omitted this info
CodeToad
javascript-events sleep wait event-bubbling
EDIT: in response to comments about executing click event programaticaly on the anchor element, or using, window.open- I cant use these because of the popup blocker. I must allow the original mouseclick event on the anchor by the user to complete its course- resulting in an unblocked new window.It seems like the best compromise here is to execute a synchronious ajax request- and present the user with a spinner gif until the request completes.EDIT: fiddle http://jsfiddle.net/cXdJg/35/Consider th
Anantha Subramaniam
c++ winapi memory-leaks thread-safety wait
I settled down on using Wait Functions ( WaitForSingleObject,WaitForMultipleObject etc) for proper thread exit. In this case , the question is do i need to explicitly call CloseHandle ( Thread Handle ) to avoid memory leak or the wait function cleans up and closes the handle on its own? In case if CloseHandle needs to be explicitly called , will i be able to call “CreateThread ( same Thread Handle ) again? Will i be able to call GetExitCodeThread( ) again ?NOTE : One StackOverFlow Question answe
Carvefx
javascript jquery load wait
I need to dynamically load jQuery and jQuery UI from a javascript, then check if it has loaded and do something afterwards.function loadjscssfile(filename, filetype){if (filetype==”js”){ //if filename is a external JavaScript filevar fileref=document.createElement(‘script’);fileref.setAttribute(“type”,”text/javascript”);fileref.setAttribute(“src”, filename);}else if (filetype==”css”){ //if filename is an external CSS filevar fileref=document.createElement(“link”);fileref.setAttribute(“rel”, “sty
vzhen
jquery wait
I have a$(‘.abc’).click(function(){ });Then I have a function which is doing append-ing jobfunction foo(){ $(‘foo’).append(‘<div>’); }And another element which is $bar.show();abc .click will process both foo() and $bar.show(); So my question is how to wait until foo() finished load then just show up $bar.show();
shaantanupareek
c++ fork pipe wait
I have written a basic c++ program in unix with fork() and wait() system call. I am only creating one child. I have used two pipes. So After fork operation with first pipe i am writing from child to parent and as after parent receives the data, parent is writing back to child in second pipe. after that in parent side I am using wait(0) system call. but still my parent process dies before child process?structure is something like this:main()char buff[] = “Parent process kills”;char cuff[] = “befo
Assaf Malki
java multithreading wait notify
I have this piece of codepublic MultiThreadedSum(ArrayBuffer ArrayBufferInst) {this.ArrayBufferInst = ArrayBufferInst;Sum = 0;Flag = false;StopFlag = false; }public synchronized void Sum2Elements() {while(Flag){try {wait();}catch (InterruptedException e){}}Flag = true;if (StopFlag){notifyAll();return;}System.out.println(“Removing and adding 2 elements.”);Sum = ArrayBufferInst.Sum2Elements();notifyAll(); }public synchronized void InsertElement() {while(!Flag){try {wait();}catch (InterruptedExcept
qodeninja
jquery ajax wait getscript
Basically what I’m doing is checking for the existence of an object, if it’s not found, the script will try to load the source file using getScript. I only want to check this once though then return true or false to the function that calls fetch()fetch:function(obj){…isReady = false;$.getScript(obj.srcFile,function(){isReady=true;warn(“was able to load object “+key);});return isReady;}but return kicks in before the script loads =/later the script is loaded but the function returned false.This
Bilo Chan
php sleep wait printing-web-page
I have read some posts and did some research before asking, if there was any duplicate post sorry about that.It is a bit similar to this question, but I don’t want the webpages to keep looping and I want the webpages to display in each iframe separately. I want to display some website with iframe every N second, the expecting result just like the following command code:@echo off echo “Webpage 1” timeout 5 >nul echo “Webpage 2” timeout 3 >nul echo “Webpage 3” timeout 4 >nulwhen I try to
user1745842
pthreads mutex condition wait
#include<pthread.h> #include<stdio.h> #include <errno.h> pthread_cond_t done; pthread_mutex_t mutex; void*cond_wait(void*p){ while(1){ printf(“%dwait\n”,(int)p); pthread_cond_wait(&done,&mutex); printf(“%dwakeup\n”,(int)p); }} int main(){ int status; int i=1; pthread_t p; status=pthread_mutex_init(&mutex,NULL); pthread_mutex_lock(&mutex); pthread_cond_init(&done,NULL); pthread_create(&p,NULL,cond_wait,(void*)1); while(1){ sleep(1); pthread_cond_signal(&a
assylias
java multithreading wait monitor synchronized
I wanted to verify in my own eyes the different between sleep and wait.Wait can only be done in a synchronized block because it releases the ownership of the monitor lock. While sleep is not related to the monitor lock and a thread that is already the owner of the monitor lock shouldn’t lose its ownership if sleeping.For that i made a test:Steps:Started a thread that waits in a synched block for 5 secs. Waited 3 secs and started another thread that acquires the monitor lock (because Thread-A is
erikb85
java awt wait
Loading the image one time works as done in the following steps (for code see end of post):load the URI with the Toolkit load the image from the URI use a MediaTracker to check the loading(waitForAll()) change the viewports size according to the image (repaint() tried here, didn’t change anything)The resizing will be done in “no time” and after that it takes a second or two that the image actually is shown (maybe because of my slow computer). If I put a while(true) around that without letting hi
Web site is in building
I discovery a place to host code、demo、 blog and websites.
Site access is fast but not money