Multi-threaded GUI
Kagamin
spam at here.lot
Thu Jul 26 04:58:52 PDT 2012
On Thursday, 26 July 2012 at 09:46:26 UTC, Gor Gyolchanyan wrote:
> So the good way to do this will be to have a single thread,
> which pumps
> messages and distributes the appropriate message handlers to
> worker
> threads, right?
>
> My goal here is to have 100% working and responsive GUI no
> matter how bad
> the application lags. If, for instance, The user would push a
> button, which
> initiates a very expensive computation, I don't want the GUI to
> become
> stuck. If the user doesn't wait and pushes the button again, it
> should
> display a message, which says "The operation is already in
> progress" or
> something like that.
Are you sure you can create a complex window fast enough when
every operation is asynchronous? I usually find applications
built with complex ui frameworks start slow. Isn't it because it
takes long to create a window going through all the framework
infrastructure?
About separation of ui logic and business logic I suggest to look
at MVVM pattern (or PresentationModel according to Fowler's
terminology). Well, it doesn't allow ad-hoc code and implies
extensive design work for every View, but by ensuring that the
ViewModel contains only plain data, you're guaranteed that
business logic is separated from ui logic.
More information about the Digitalmars-d
mailing list