Hello everyone,
I am a bit new to ThreadPool in .NET. I was wondering, if I can only send one object to my callback method, how am I able to access the class member variable to call its methods? (see customClass in CallBack())
And how would I load the data from customClass? Do I pass the customClass to a different CallBack method? is this approach alright?
As you can see it is a bit of lack of experience, so any tips along the way would really be appreciated.
Thank you, Kave
class Program
{
static void Main(string[] args)
{
CustomClass customClass = new CustomClass();
ThreadPool.QueueUserWorkItem(CallBack, "Hello");
Console.Read();
}
private static void CallBack(object state)
{
customClass.SaveData(state.ToString());
}
}