[Gtk-sharp-list] ThreadNotify: The saga continues

Pablo Baena pbaena@uol.com.ar
28 Oct 2002 16:46:07 +0000


--=-NFJr4HdlFcb8w9unVmKb
Content-Type: text/plain
Content-Transfer-Encoding: 7bit

Hi!

    This kind of problem does not seem to require threads.  
    
    What kind of progress monitoring are you doing?
    

I am running a process with Process and a thread examines its output,
checking, among other things, the progress. 

    You can either use timeouts for polling, or you could use GIO and watch
    a file descriptor for activity (this is probably what you want) and wake
    up your process only when the child process has done something.   
    
    See, your thread monitoring the process currently has to do one of:
    
    	* Loop in: Check and wait for some time.
    
    	or
    
    	* Loops busily checking.
    
    	or
    
    	* Block until something happens in the child (file descriptor)
    
    Waiting busily is a bad idea because you consume CPU that you do not
    really need to.  Block until something happens in child can be achieved
    with GIO watches, and loop with check and wait for some time is just
    gtimeout.
    
    Miguel
    

What you suggest would require the use of extern glib methods for
running the process, right? And in the case I do this, how can I wait
for data on the fd and still have my application responsive to the other
events?

Pablo

--=-NFJr4HdlFcb8w9unVmKb
Content-Type: text/html; charset=utf-8

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 TRANSITIONAL//EN">
<HTML>
<HEAD>
  <META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=UTF-8">
  <META NAME="GENERATOR" CONTENT="GtkHTML/1.0.4">
</HEAD>
<BODY>
Hi!
    <BLOCKQUOTE>
<PRE><FONT COLOR="#737373"><FONT SIZE="3"><I>This kind of problem does not seem to require threads.  </FONT></FONT></I>
<FONT COLOR="#737373"><FONT SIZE="3"><I></FONT></FONT></I>
<FONT COLOR="#737373"><FONT SIZE="3"><I>What kind of progress monitoring are you doing?</FONT></FONT></I>
<FONT COLOR="#737373"><FONT SIZE="3"><I></FONT></FONT></I></PRE>
    </BLOCKQUOTE>
<FONT SIZE="3">I am running a process with Process and a thread examines its output, checking, among other things, the progress. </FONT>
    <BLOCKQUOTE>
<PRE><FONT COLOR="#737373"><FONT SIZE="3"><I>You can either use timeouts for polling, or you could use GIO and watch</FONT></FONT></I>
<FONT COLOR="#737373"><FONT SIZE="3"><I>a file descriptor for activity (this is probably what you want) and wake</FONT></FONT></I>
<FONT COLOR="#737373"><FONT SIZE="3"><I>up your process only when the child process has done something.   </FONT></FONT></I>
<FONT COLOR="#737373"><FONT SIZE="3"><I></FONT></FONT></I>
<FONT COLOR="#737373"><FONT SIZE="3"><I>See, your thread monitoring the process currently has to do one of:</FONT></FONT></I>
<FONT COLOR="#737373"><FONT SIZE="3"><I></FONT></FONT></I>
<FONT COLOR="#737373"><FONT SIZE="3"><I>	* Loop in: Check and wait for some time.</FONT></FONT></I>
<FONT COLOR="#737373"><FONT SIZE="3"><I></FONT></FONT></I>
<FONT COLOR="#737373"><FONT SIZE="3"><I>	or</FONT></FONT></I>
<FONT COLOR="#737373"><FONT SIZE="3"><I></FONT></FONT></I>
<FONT COLOR="#737373"><FONT SIZE="3"><I>	* Loops busily checking.</FONT></FONT></I>
<FONT COLOR="#737373"><FONT SIZE="3"><I></FONT></FONT></I>
<FONT COLOR="#737373"><FONT SIZE="3"><I>	or</FONT></FONT></I>
<FONT COLOR="#737373"><FONT SIZE="3"><I></FONT></FONT></I>
<FONT COLOR="#737373"><FONT SIZE="3"><I>	* Block until something happens in the child (file descriptor)</FONT></FONT></I>
<FONT COLOR="#737373"><FONT SIZE="3"><I></FONT></FONT></I>
<FONT COLOR="#737373"><FONT SIZE="3"><I>Waiting busily is a bad idea because you consume CPU that you do not</FONT></FONT></I>
<FONT COLOR="#737373"><FONT SIZE="3"><I>really need to.  Block until something happens in child can be achieved</FONT></FONT></I>
<FONT COLOR="#737373"><FONT SIZE="3"><I>with GIO watches, and loop with check and wait for some time is just</FONT></FONT></I>
<FONT COLOR="#737373"><FONT SIZE="3"><I>gtimeout.</FONT></FONT></I>
<FONT COLOR="#737373"><FONT SIZE="3"><I></FONT></FONT></I>
<FONT COLOR="#737373"><FONT SIZE="3"><I>Miguel</FONT></FONT></I>
</PRE>
    </BLOCKQUOTE>
What you suggest would require the use of extern glib methods for running the process, right? And in the case I do this, how can I wait for data on the fd and still have my application responsive to the other events?
<BR>

<BR>
Pablo
</BODY>
</HTML>

--=-NFJr4HdlFcb8w9unVmKb--