I read this article the other day and was unsatisfied by the concepts
described:
http://msdn.microsoft.com/library/de...ml/asyncui.asp
Essentially, it discussed how to best implement asynchronous processing from
the UI. That's nice, but the article is limited in its scope. What I'd
like to see an article about, or hear comments on, is how to implement an
asynchronous Business Objects layer that exists on a separate thread from
the GUI and is able to handle the processing of asynchronous server events.
For example, let's say you have an application that maintains a persistent
TCP/IP socket connection with a back-end application. It needs to be
persistent so that the application can get asynchronous updates in
real-time. The application's business logic layer would be responsible for
processing incoming/outgoing data for this socket connection, and
maintaining an in-memory cache of the current application data set. In
order to provide a more responsive UI, it seems it would make sense to have
a separate thread that manages the business logic layer (and thus the
internal data set), and then once received data has been fully processed and
cached, the business logic layer would notify the UI that it needs to be
refreshed.
I haven't found any reasonable way to keep a worker thread alive such that
it could wait around and handle any delegate callbacks. Therefore, my idea
is to create a Business Logic class that inherits from
System.Windows.Forms.Control. This would allow me to create a new GUI
thread that is separate from the main GUI thread. This new thread could be
used to process any asynchronous callbacks from objects that are owned by
the Business Logic class. Then, various GUI objects could "register"
delegate callbacks with the Business Logic class. The drawback to this is
that it would potentially involve a lot of thread switching, and would thus
potentially cause more performance problems than if the Business Logic
processing existed on the main GUI thread.
I'd appreciate any comments regarding this approach. In particular, I am
most interested in evaluating the merits of alternative approaches to
maintaining a Business Logic layer that is functionally independent of the
main GUI thread.
Regards,
MP
Michael.Pouliot-(E-Mail Removed)