Multiple Asynchronous request in c#

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • coolnags
    New Member
    • Oct 2008
    • 10

    #1

    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 EmployeeCallbac k(Employee emp);
    private static string UpdateName(Empl oyee emp)
    {
    return emp.FirstName;
    }
    public static void Main()
    {
    string appstr = string.Empty;
    Employee emp1 = new Employee("Marin a", "jimnez", 7000m);
    Employee emp2 = new Employee("wilso n", "joe", 7000m);
    Employee[] emps = new Employee[3];
    emps[0] = emp1;
    emps[1] = emp2;
    Department dep = new Department(emps , "IT");
    EmployeeCallbac k updateCallback = new EmployeeCallbac k(UpdateName);
    foreach (Employee emp in emps)
    {
    result = updateCallback. BeginInvoke(emp , callbackfunctio n,null);
    }
    string finalstring = updateCallback. EndInvoke(resul t);
    Console.ReadLin e();
    }
    }

    Regards,
    Nagu
Working...