On Wed, Jul 25, 2012 at 10:50 PM, Simon
<s.d.hammett@gmail.com> wrote:
On 25/07/2012 19:34, Gor Gyolchanyan wrote:
Hi!
I'm trying to write a WinAPI example to have multi-threaded GUI. I wanna
have a Window class, which creates a window and listens to its messages
in a separate thread when constructed. This will allow me to write a
main function like this:
void main()
{
Window w = new Window;
w.move(100, 200);
w.resize(800, 600);
w.show();
}
The methods called for the window will send asynchronous messages, which
will cause the window to change its position, size and visibility
on-the-fly. This is convenient, because no message loop needs to be
launched separately and every window will rocess its messages in a
separate thread.
Can anyone please tell me how to achieve this?
--
Bye,
Gor Gyolchanyan.
It depends exactly on what you are trying to do, but in general:
You have to be very, very careful with trying to do multi threading w/ windoze windows. Try doing a google search on it, and the advice is invariably: don't do multi threaded windows. Everybody including people famous for their in-depth window knowledge recommends a single thread UI with non-UI worker threads.
Having completely separate top level windows each in it's own thread is ok, but if you want to have a parent/child relation between windows in different threads, then you can not use any thread synchronisation primitives all at other than MsgWaitForMultipleObjectsEx, otherwise you will have a guaranteed deadlock. In which case you'd have to do all of the threading your self and not use anything in phobos.
--
My enormous talent is exceeded only by my outrageous laziness.
http://www.ssTk.co.uk