P
Pavils Jurjans
(I am sorry to crosspost both here and in asp.net group. I think, this
question quite certainly belongs better to this group, but by error I posted
the question to asp.net group)
Hello,
I am reading the article
http://msdn.microsoft.com/msdnmag/issues/04/01/BasicInstincts/ , and, since
the sample code is VB.NET, I am wondering what the heck is the "Invoke"
method I used to think that I can simply directly call the delegate
type instance with parameters:
public class Executer
{
public delegate bool TestDelegateType(string strValue);
static bool TestDelegateMethod(string strValue)
{
Console.WriteLine("TestDelegateMethod got value:" + strValue);
return strValue == "ABC";
}
static void Main( )
{
TestDelegateType TestDelegate = new TestDelegateType(TestDelegateMethod);
// Simple call
bool result = TestDelegate("ABC");
Console.WriteLine("Call to TestDelegate returned: " + result);
Console.ReadLine();
}
}
As far as I know, I can not do anything like TestDelegate.Invoke("ABC",
null, null) in C#? So, apparently there is some syntax issue in VB.NET
preventing the direct execution of delegate, and it has to do it via Invoke
method? Please, clear this up for me, so I can have better understanding of
samples where there is no C# code.
Taking it further, what is the simplest C# syntax of launching the given
delegate asynchorously?
Thanks,
Pavils
question quite certainly belongs better to this group, but by error I posted
the question to asp.net group)
Hello,
I am reading the article
http://msdn.microsoft.com/msdnmag/issues/04/01/BasicInstincts/ , and, since
the sample code is VB.NET, I am wondering what the heck is the "Invoke"
method I used to think that I can simply directly call the delegate
type instance with parameters:
public class Executer
{
public delegate bool TestDelegateType(string strValue);
static bool TestDelegateMethod(string strValue)
{
Console.WriteLine("TestDelegateMethod got value:" + strValue);
return strValue == "ABC";
}
static void Main( )
{
TestDelegateType TestDelegate = new TestDelegateType(TestDelegateMethod);
// Simple call
bool result = TestDelegate("ABC");
Console.WriteLine("Call to TestDelegate returned: " + result);
Console.ReadLine();
}
}
As far as I know, I can not do anything like TestDelegate.Invoke("ABC",
null, null) in C#? So, apparently there is some syntax issue in VB.NET
preventing the direct execution of delegate, and it has to do it via Invoke
method? Please, clear this up for me, so I can have better understanding of
samples where there is no C# code.
Taking it further, what is the simplest C# syntax of launching the given
delegate asynchorously?
Thanks,
Pavils