N
Nick
Hi,
I was just playing around and found that the following two ways of
calling the same method using the WaitCallback method that takes an
object parameter. Can any one explain why there is no problem with the
first call even though the delegate doesn't take in the Object
Parameter??? What is the complier doing "under the covers".
Thanks for any help
Nick
Object state = new Object();
// Using WaitCallback
// Note no parameter passed in
WaitCallback oInvokeNoParameter = delegate {
MyMethodCall(); };
oInvokeNoParameter.Invoke(state);
WaitCallback oInvokeAParameter = delegate(Object oObject) {
MyMethodCall(); };
oInvokeAParameter.Invoke(state);
.......
static void MyMethodCall()
{
Console.WriteLine("MyMethodCall has been invoked");
}
I was just playing around and found that the following two ways of
calling the same method using the WaitCallback method that takes an
object parameter. Can any one explain why there is no problem with the
first call even though the delegate doesn't take in the Object
Parameter??? What is the complier doing "under the covers".
Thanks for any help
Nick
Object state = new Object();
// Using WaitCallback
// Note no parameter passed in
WaitCallback oInvokeNoParameter = delegate {
MyMethodCall(); };
oInvokeNoParameter.Invoke(state);
WaitCallback oInvokeAParameter = delegate(Object oObject) {
MyMethodCall(); };
oInvokeAParameter.Invoke(state);
.......
static void MyMethodCall()
{
Console.WriteLine("MyMethodCall has been invoked");
}