notification across threads

BCS ao at
Tue May 13 10:15:59 PDT 2008

Reply to luke,

> 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?

One option would be to put a thread safe queue of delegates in the main thread. 
Then the slot code just stuffs an action into it. Then the main thread, at 
some point, run everything in the queue:

while(queue.notEmpty) queue.dequeue();

not to perdy but it would get the job done for some cases. What would be 
niceer would be some sort of interupt, but I don't known how to do that.

More information about the Digitalmars-d-learn mailing list