Thread.start doesn't work?

Frank Benoit keinfarbton at googlemail.com
Thu Jul 31 21:26:40 PDT 2008


Plumm schrieb:
> The code is as follows: The problem is if some exception happens, it
> should open up a messagebox(messagebox works without being inside a
> thread), and I haven't tested the code without the DWT environment,
> but I think it might be the Tango problem, not the DWT problem. This
> code works if it's not in a thread though.
> 


It is not allowed to access any DWT function from a thread that is not 
the "GUI thread". The calls to MessageBox in the thread might throw 
exception, because they detect an illegal thread access.

To solve this, there is Display.syncExec and asyncExec.

Display.getCurrent().syncExec( dgRunnable({
                MessageBox messageBox0 = new 
MessageBox(DWT.OK|DWT.ICON_INFORMATION);
                messageBox0.setText("Done");
                messageBox0.setMessage(sprint0("{} Lines", int_lines));
                messageBox0.open();

}));


More information about the Digitalmars-d-dwt mailing list