[Prev][Next][Index][Thread]

Re: help with DUIM application




John Whittaker wrote in message ...
>What would be the correct way to use DUIM to create an application which
>periodically (about 1 Hz) reads a sequence of data received via a serial
>port and translates the data for display in a simple dialog window?
>
>My first thoughts were:
>
>1.  Have two threads.  One for the serial input task and one for the
display
>task.  Assuming that to be the design, what is the proper way in DUIM to
>signal the display task that new data is available for translation and
>display.  I know that DUIM has event queue processing, but I don't know how
>it works.  Would it make sense to define a new subclass of <event>, say
><io-ready-event>,  and use it to signal from the serial input task to the
>display task?  The display task would, of course, somehow have to have a
>modified event loop that recognizes the new class <io-ready-event>.  The
>event handling for the event in the display task would be to grab the data
>from the input task and then translate and display it.
>
>2.  The other idea I had was to simply call the serial input function at a
>rate of approximately once per second.  Well, how do you accomplish timed
>periodic events in DUIM?  Or is there some other event in the Win32 API
that
>I could use?
>
>I'm not an expert on either DUIM or Win32, so pardon if the answer is
>obvious to the DUIM/Win32 experts.


If I were doing it, I would use two threads.  Because of some
Windows idiosyncracies, you are best off using the initial thread
to manage your user interface, and start a different thread to
manage the serial input.  Use the threads library, and have the
first thread await some sort of signal from the serial input thread.

You could look at the Life example to see how a multi-threaded
DUIM app works.  The UI thread draws the display and handles
inout events, such as the user selecting something from a menu.
The "compute" thread (which corresponds to your serial input
thread) computes each new generation and notifies the UI thread
when a new generation is fully computed.







Follow-Ups: References: