www.digitalmars.com         C & C++   DMDScript  
Archives

D Programming
digitalmars.D
digitalmars.D.bugs
digitalmars.D.dtl
digitalmars.D.ide
digitalmars.D.dwt
digitalmars.D.announce
digitalmars.D.learn
digitalmars.D.debugger
D.gnu
D

C/C++ Programming
c++
c++.announce
c++.atl
c++.beta
c++.chat
c++.command-line
c++.dos
c++.dos.16-bits
c++.dos.32-bits
c++.idde
c++.mfc
c++.rtl
c++.stl
c++.stl.hp
c++.stl.port
c++.stl.sgi
c++.stlsoft
c++.windows
c++.windows.16-bits
c++.windows.32-bits
c++.wxwindows

digitalmars.empire
digitalmars.DMDScript
electronics


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