"Jeff" <do***@spam.mewrote in message
news:u%****************@TK2MSFTNGP04.phx.gbl...
thanks, I understand that now
However there are something here I don't understand. I'm trying to
understand some .NET code using delegates. Below is another example which
I
have trouble understanding. The example is taken from an app I'm
programming
on (names on methods are changed):
Something mystifies me in this code:-
delegate decimal HelloWorldHandler(string name);
private decimal HelloWorld(string name)
{
}
public int World(string name)
{
IAsyncResult aResult;
HelloWorldHandler handler = delegate(string name) {return decimal;};
aResult = handler.BeginInvoke(name, null, null, null);
Where does the BeginInvoke method come from? The base Delegate abstract
type doesn't have it.
>
if (!aResult.IsComplete)
aResult.AsyncWaitHandle.WaitOne();
decimal var1 =
((HelloWorldHandler)((AsyncResult)aResult).AsyncDe legate).EndInvoke(aResult)
;
Ditto for EndInvoke?
}
There are lot of things I don't know here. Here no HelloWorldHandler foo =
HelloWorld; are used.. how can it still know what method to execute??
AFIAK the example above creates a delegate which execute in it's own
thread.
started by BeginInvoke. and aResult.IsComplete check if the method
reference
by the delegate is finished. And EndInvoke is called to retrieve the
result
from the method.
Am missing something fundemental and just having an off day?
--
Anthony Jones - MVP ASP/ASP.NET