المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Thread of a delegate



C# Programming
07-01-2009, 06:00 PM
Hi all,

I would like in C# to initialize a thread with a delegate. It looks like this :

internal delegate void MyDelegateType();
internal MyDelegateType MyDelegate;

public Init_Launch_Thread()
{
Thread lThread_Groupe = new Thread(MyDelegate); //Is not allowed
lThread_Groupe.Start();
}


It is not allowed and I do not really get why. My problem is that I do not know before construction of my class what actually will be launched in the thread. Is anyone got an idea ? I would like to avoid polymorphism there for other reasons.
thx