views:

23

answers:

1

Hi,

I am following sample code on implementing MVVM in Silverlight (see: http://msdn.microsoft.com/en-us/magazine/dd458800.aspx). On page 5 (when printed), the author has the following segment of code:

qry.BeginExecute(new AsyncCallback => a
{
    try
    {
        IEnumerable<Game> results = qry.EndExecute(a);

        if (GameLoadingComplete != null)
        {
            GameLoadingComplete(this, new GameLoadingEventArgs(results));
        }

... etc.

From the call to BeginExecute: Is this saying execute the code in the lamda expression asynchronously, or once the query (BeginExecute) completes, call the code in the lamda ?

Thanks,

Scott

+1  A: 

IAsyncResult pattern says that AsyncCallback will be executed after query is completed. You can read more about working with BeginXXX/EndXXX methods here: http://msdn.microsoft.com/en-us/library/ms228963.aspx

Chriso