notification across threads

Luke fake at fakemail.fake
Tue May 13 12:35:06 PDT 2008

Luke Wrote:

> I am pretty new to D but I'm enjoying the language so far. I'm writing an application (basically just for learning purposes) in which I create a new thread and then want my main thread to do some work (update the GUI) after the spawned thread has completed. The main thread has a DWT GUI running so I do not want that to be locked up until the "worker" thread completes. I tried using signals/slots but the slot code gets executed in the same thread from which the signal is emitted. Is there a way to have that slot code executed in the main thread or something similar?

Thanks for the suggestions. Naturally, I read them and then decided to try something else. :)

I've figured out something that works but I'd be interested to know if anyone advises against using this approach. Since I'm using DWT, I use "asyncExec"  to emit my signal when the thread function completes. The code in the associated slot then gets run in the main thread and everything seems to work.

private void threadFunc()
        Stdout.formatln("thread starting...");        
        Stdout.formatln("{} finished",;
        m_display.asyncExec(new class () Runnable
            public void run() 

One thing I don't like about this is that now my non-Gui code has to know about some DWT stuff (Display & Runnable). Any other drawbacks to this?

Thanks again.

More information about the Digitalmars-d-learn mailing list