Here is my Main
class code:
DelegateClass dc = new DelegateClass();
MyDelegate mydelegate = new MyDelegate(dc.WriteName);
ParameterLess paramless = new ParameterLess(dc.ShowName);
IAsyncResult mydelresult = mydelegate.BeginInvoke("Some Data",null,null);
var result = mydelegate.EndInvoke(mydelresult);
Console.WriteLine("Name is {0} ", result);
IAsyncResult myparamless = paramless.BeginInvoke(null,null);
result = paramless.EndInvoke(myparamless);
Console.WriteLine("Greeting is {0} ", result);
Console.WriteLine();
Console.ReadLine();
Here is my DelegateClass
:
public string WriteName(string Name)
{
return Name;
}
public string ShowName()
{
return "Hello";
}
public string idea(string idea)
{
return idea;
}
As the definition of idea
and WriteName
are same, I want to make them a multicast delegate by using BeginInvoke and EndInvoke.Can some one tell me how to do that.Is it possible?
you can not use multicast delegate using asyn calling, because each asyn call executes on separate thread, and you have no option for second thread to execute.i-e the multicasted one.