Is this correct?
Not at all
I don't know if you're familiar with C or C++ (ignore this sentence if you
aren't) but if you are then the closest to them that you're familiar with
are function pointers.
In C# I guess you could think of them as a variable for method calls. Like
variables they have a type, and can be instantiated. An instance of a
delegate type can be called (invoked) and that will result in the method the
delegate instance points at being called.
So a delegate has a signature or type describing the kind of method it can
point to. A piece of code may say "If you want to know when I've done this
then I'll tell you - give me a delegate of such and such a type and I'll
call it when I've done it."
The bit about delegates executing on another thread - well, I don't know
where that came from, but a delegate call will execute on the same thread
that called it.
This is a bit of a loose definition, but I hope it gets you started.
Best way to figure this out is just to play with it. Create a form with a
button on and aim to pop up a message box when the button is clicked on.
That involves the use of delegates. Or type "delegate" in Visual Studio and
hit F1. That will call up the help for it.
Cheers,
Adam.
"Miro" <mi**@beero.com wrote in message
news:Oq******** ******@TK2MSFTN GP06.phx.gbl...
>I am trying to understand delegates and I think I do understand them ...
just hoping if someone can tell me im on the right track.
So far what I have read is that a Delegate is an Asynchronus call to a
method or function or whatever...
So basically you create an object that references the address of the
meathod.
By calling this delegate - you get a 'return' right away so your code can
continue and the delegate runs in a different thread doing whatever the
function / meathod is required.
Is this the correct assumption?
The example in the book is pretty simple ( its a writeline command ).
So as far as 'uses' for delegates ( if im on the right track )...its
useful when you have a lot to process, but do not want to do it in the
main thread ( or the app will temporarily stop working ), you use a
delegate to call the meathod in a different thread.
Is this correct?
Thanks,
Miro