[Gtk-sharp-list] ThreadNotify: The saga ended...:)
Pablo Baena
pbaena@uol.com.ar
30 Oct 2002 15:18:09 +0000
--=-qaWoSOaAb0RdfxPAOHzk
Content-Type: text/plain
Content-Transfer-Encoding: 7bit
I think I found the best solution to my problem. I made a custom class
derived from Queue, and did override Queue.Enqueue to raise an event
whenever it is used.
Now when one thread puts something in the Queue, it automatically raises
the event, and the event handler calls ThreadNotify.WakeupMain. This way
my back end utilities just communicate via the queue and know nothing
about ThreadNotify, and voila', the uggliness is gone. Also, no need to
poll the queue for new messages.
I know the negative side of using threads, but I prefer them because
they are a more natural way to express oneself when programming. I'm a
cabeza-dura, I know! :) but this is a small project, so I can afford
using them.
Thank you for the help Miguel!
Pablo
On Wed, 2002-10-30 at 04:39, Miguel de Icaza wrote:
> I am running a process with Process and a thread examines its output,
> checking, among other things, the progress.
I am pretty sure that you should be able to poll the Process output. If
we do not have a helper routine today to simplify this, we should add
it.
Miguel
_______________________________________________
Gtk-sharp-list maillist - Gtk-sharp-list@ximian.com
http://lists.ximian.com/mailman/listinfo/gtk-sharp-list
--=-qaWoSOaAb0RdfxPAOHzk
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>
I think I found the best solution to my problem. I made a custom class derived from Queue, and did override Queue.Enqueue to raise an event whenever it is used.
<BR>
<BR>
Now when one thread puts something in the Queue, it automatically raises the event, and the event handler calls ThreadNotify.WakeupMain. This way my back end utilities just communicate via the queue and know nothing about ThreadNotify, and voila', the uggliness is gone. Also, no need to poll the queue for new messages.
<BR>
<BR>
I know the negative side of using threads, but I prefer them because they are a more natural way to express oneself when programming. I'm a cabeza-dura, I know! :) but this is a small project, so I can afford using them.
<BR>
<BR>
Thank you for the help Miguel!
<BR>
Pablo
<BR>
<BR>
On Wed, 2002-10-30 at 04:39, Miguel de Icaza wrote:
<BLOCKQUOTE>
<PRE><FONT COLOR="#737373"><FONT SIZE="3"><I>> I am running a process with Process and a thread examines its output,</FONT></FONT></I>
<FONT COLOR="#737373"><FONT SIZE="3"><I>> checking, among other things, the progress. </FONT></FONT></I>
<FONT COLOR="#737373"><FONT SIZE="3"><I></FONT></FONT></I>
<FONT COLOR="#737373"><FONT SIZE="3"><I>I am pretty sure that you should be able to poll the Process output. If</FONT></FONT></I>
<FONT COLOR="#737373"><FONT SIZE="3"><I>we do not have a helper routine today to simplify this, we should add</FONT></FONT></I>
<FONT COLOR="#737373"><FONT SIZE="3"><I>it.</FONT></FONT></I>
<FONT COLOR="#737373"><FONT SIZE="3"><I></FONT></FONT></I>
<FONT COLOR="#737373"><FONT SIZE="3"><I>Miguel</FONT></FONT></I>
<FONT COLOR="#737373"><FONT SIZE="3"><I></FONT></FONT></I>
<FONT COLOR="#737373"><FONT SIZE="3"><I>_______________________________________________</FONT></FONT></I>
<FONT COLOR="#737373"><FONT SIZE="3"><I>Gtk-sharp-list maillist - Gtk-sharp-list@ximian.com</FONT></FONT></I></PRE>
</BLOCKQUOTE>
<A HREF="http://lists.ximian.com/mailman/listinfo/gtk-sharp-list"><FONT SIZE="3"><I>http://lists.ximian.com/mailman/listinfo/gtk-sharp-list</FONT></I></A>
<BLOCKQUOTE>
<PRE></PRE>
</BLOCKQUOTE>
</BODY>
</HTML>
--=-qaWoSOaAb0RdfxPAOHzk--