DWT multi thread issue
yidabu
yidabu.spam at gmail.com
Fri Oct 31 16:37:26 PDT 2008
On Fri, 31 Oct 2008 07:56:53 -0400
Frank Benoit <keinfarbton at googlemail.com> wrote:
> I cannot try it right now, but perhaps this works? :
>
> void dgRefresh()
> {
> auto runOne = new RunOne();
> Thread thread = new Thread( &runOne.run );
> thread.start();
> }
>
code works:
void dgRefresh()
{
auto runOne = new RunOne();
Thread thread = new Thread( &runOne.run );
thread.start();
}
class RunOne : Runnable
{
uint i;
void run()
{
Stdout("RunOne.run").newline;
long start = WallClock.now.span.millis;
void dgSetText(String text)
{
shell.setText(text);
}
while ((WallClock.now.span.millis() - start) < runTime)
{
auto text = "wait " ~ to!(String)(i++);
shell.getDisplay.syncExec( dgRunnable(&dgSetText, text) );
Thread.sleep(1);
}
}
}
My question is :
in dwt-samples\user\torhu_synctest.d, code works:
auto t = new Thread({Display.getDefault.syncExec(new class Runnable {
void run() { txt.setText("inside syncExec"); }
});});
where code here not work:
void dgRefresh()
{
auto runOne = new RunOne();
Thread thread = new Thread( { shell.getDisplay.syncExec(runOne); } );
thread.start();
}
--
yidabu <yidabu.spam at gmail.com>
http://www.dsource.org/projects/dwin
D 语言-中文(D Chinese):
http://www.d-programming-language-china.org/
http://bbs.d-programming-language-china.org/
http://dwin.d-programming-language-china.org/
http://scite4d.d-programming-language-china.org/
More information about the Digitalmars-d-dwt
mailing list