J
Jerry S
Hi
This is probably simple, but can anyone explain why this won't work:
public void SomeMethod()
{
//Do stuff
}
ThreadStart myThreadDelegate = new ThreadStart(SomeMethod);
Thread myThread = new Thread(myThreadDelegate);
It gives me a "A field initializer cannot reference the nonstatic
field, method, or property..." error.
If I make the SomeMethod static, then it works properly. But if the
method is static then it can't access other non-static methods from
the class, so that's no good.
I realise that I'm not getting what's happening here because I know
virtually nothing about threads!
Thanks.
Jerry
This is probably simple, but can anyone explain why this won't work:
public void SomeMethod()
{
//Do stuff
}
ThreadStart myThreadDelegate = new ThreadStart(SomeMethod);
Thread myThread = new Thread(myThreadDelegate);
It gives me a "A field initializer cannot reference the nonstatic
field, method, or property..." error.
If I make the SomeMethod static, then it works properly. But if the
method is static then it can't access other non-static methods from
the class, so that's no good.
I realise that I'm not getting what's happening here because I know
virtually nothing about threads!
Thanks.
Jerry