www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - d2 shared delegate problem

Hello everybody, directly to my problem:

In class A I got a static array of delegates...

class A{

private static alias void delegate() EventHandler;
public static EventHandler[] MyEvent;

static void Foo()
{
foreach(eh; MyEvent) eh();
}

}

...and when I call Foo() from another Thread like...

import core.thread;
void main()
{

A.MyEvent~=() { std.stdio.writeln("MyEvent"); }

Thread th=new Thread((){
A.Foo();
});
th.start();

}

...my program says anything...so I set MyEvent to be shared...
But now, after running my program it says that there is a stack overflow...

Where's the reason for this?
May 24 2009