You must Sign In to post a response.
  • Category: .NET

    How to enforce a function to call a call back function

    Hi All,
    We have a situation. there are 2 classes in business logic layer. These classes have multiple functions which perform Insert / Update on a table.
    There is another database operation which needs to be done after each of these function execution.

    Thus, wanted to know how we can enforce these to classes functions to call a call back function after their execution.

    Eg:

    Class C1 has f1 & f2 functions. there is other class called C2 which has a afterfunc() function. We want after f1 & f2 execution afterfunc() get called.
  • #765271
    Hi,
    Simply create object of class C2 after f2 function and call afterfunc() using that object as follows:
    f1();
    f2();
    C2 obj = new C2();
    obj.afterfunc();
    Hope it will be helpful to you.
    Regards,
    Shashikant Gurav

  • #765274
    Hi,

    If you want to execute the class1 functions first then class2 function, then create the instances of both the classes and then call it as you want.

    Ex:

    class1 obj1=new class1();
    obj1.fun1();
    obj1.fun2();

    class2 obj2=new class2();
    obj2.fun1();


    Hope this will helpful to you...

    --------------------------------------------------------------------------------
    Give respect to your work, Instead of trying to impress your boss.

    N@veen
    Blog : http://naveens-dotnet.blogspot.in/


Sign In to post your comments