-----------------------------------------------------------

New Message on MumbaiUserGroup

-----------------------------------------------------------
From: VishalRJoshi
Message 42 in Discussion

 Callback functions

Callback functions are powerful tools and we should know how to use them...
In general a callback function is a reference to a method that you pass to
another method... When the second method calls the referenced method , it
actually calls back to the first method... This might be a confusing
terminology but a code snippet from MSDN will probably help make it
clearer...

using System;
using System.Runtime.InteropServices;

public delegate bool CallBack(int hwnd, int lParam);

public class EnumReportApp {

    [DllImport("user32")]
    public static extern int EnumWindows(CallBack x, int y); 

    public static void Main() 
    {
        CallBack myCallBack = new CallBack(EnumReportApp.Report);
        EnumWindows(myCallBack, 0);
    }

   public static bool Report(int hwnd, int lParam) { 
        Console.Write("Window handle is ");
        Console.WriteLine(hwnd);
        return true;
    }
}

Here is the link for you to explore more.... 
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/htm
l/cpconusingcallbackfunctions.asp

PS: I have coined a new term called "Developer's Superstition"... I suffer
from this problem often - When code does not seem to behave the way I want
it to, knowingly/unknowingly I try things which I know will not work, which
I know are technically impossible but still I do just to make myself feel
good that I have left no stones unturned... I wonder whether you guys also
do such thing... A classic example would be trying to call GC.Collect()
method when a StreamReader is not releazing a file even after calling
close()...{usually its some other process holding the reference...:-)} I
wonder has MS Technologies made me superstitious or is this same
everywhere... :-)
 
Vishal Joshi
Microsoft MVP .Net
       If You Think YOU CAN... You Can...
http://VishalJoshi.Blogspot.com 
http://www.microsoft.com/india/mvp/indiamvp.aspx
http://groups.msn.com/ChennaiNetUserGroup 
http://groups.msn.com/CNUG-DAM 
http://groups.msn.com/NetBloomingtonUserGroup



-----------------------------------------------------------

To stop getting this e-mail, or change how often it arrives, go to your E-mail 
Settings.
http://groups.msn.com/MumbaiUserGroup/_emailsettings.msnw

Need help? If you've forgotten your password, please go to Passport Member Services.
http://groups.msn.com/_passportredir.msnw?ppmprop=help

For other questions or feedback, go to our Contact Us page.
http://groups.msn.com/contact

If you do not want to receive future e-mail from this MSN group, or if you received 
this message by mistake, please click the "Remove" link below. On the pre-addressed 
e-mail message that opens, simply click "Send". Your e-mail address will be deleted 
from this group's mailing list.
mailto:[EMAIL PROTECTED]

Reply via email to