Multiple Asynchronous request in c#
I have a situation in which i need to give multiple calls to delegates asynchronously and get the responses. In this code Employee is a class.
I need a callback function which actually gets me both the employees names together.
Ex: class Program
{
public delegate string EmployeeCallback(Employee emp);
private static string UpdateName(Employee emp)
{ return emp.FirstName; }
public static void Main()
{
string appstr = string.Empty;
Employee emp1 = new Employee("Marina", "jimnez", 7000m);
Employee emp2 = new Employee("wilson", "joe", 7000m);
Employee[] emps = new Employee[3];
emps[0] = emp1;
emps[1] = emp2;
Department dep = new Department(emps, "IT");
EmployeeCallback updateCallback = new EmployeeCallback(UpdateName);
foreach (Employee emp in emps)
{ result = updateCallback.BeginInvoke(emp, callbackfunction,null); }
string finalstring = updateCallback.EndInvoke(result);
Console.ReadLine();
}
}
Regards,
Nagu