Component index
Section index

Component uithread


	    The following example grab the information produced by a process and
	    fill a table (editrecord). One uithread is used to collect the data
	    and a PRIVATE_MESSAGE is used to signal the editrecord thread.
	    This sample also show how one thread may ask another to end using
	static void sample_uithread_popen()
	    glocal SSTRINGS data;
	    glocal PRIVATE_MESSAGE samples,ending;
	    <call uithread>();
	    <f thread1>
	        <call walkpopen>("/tmp/x output 100",1,true);
	        <f wait>
	                We are using diagui_sync() to make sure the other dialog
	                are still alive.
	            int ret = diagui_sync (pop,timeout,true);
	            if (dialog_testmessage(glocal.ending)){
	                end = true;
	            return ret;
	        <f oneline>
	   (new SSTRING(line));
	            dialog_sendmessage (glocal.samples);
	    <f thread2>
	        <call editrecords>("Some records","",help_nil);
	        <f head>
	            waitfor (glocal.samples);
	            newf_head ("column1\tcolumn2\tcolumn3");
	            setvsize (10);
	        <f load>
	            for (int i=0; i<; i++){
	                const char *s =>get();
	                char tmp[strlen(s)+1];
	                strcpy (tmp,s);
	                char *pt = tmp;
	                while (*pt != '\0'){
	                    if (*pt == ' ') *pt = '\t';
	                SSTRING word;
	                pt = str_copyword (word,tmp);
	                new_menuitem (word.get(),pt);
	        <f editone>
	            printf ("Line %d was selected\n",no);
	        dialog_sendmessage (glocal.ending);