EndRetrieve Method

Ends an asynchronous cache response retrieval started by the BeginRetrieve method.

Namespace:  Microsoft.Web.Media.SmoothStreaming
Assembly:  Microsoft.Web.Media.SmoothStreaming (in Microsoft.Web.Media.SmoothStreaming.dll)

CacheResponse EndRetrieve(
	IAsyncResult ar


Type: System..::..IAsyncResult
An IAsyncResult object.

The method will block until done if necessary and may be called on any thread. Simple cache objects must return as quickly as possible. If the caching object takes more than approximately 100 milliseconds, it is likely that the SmoothStreamingMediaElement will ignore the response.

A Silverlight IIS Smooth Streaming Offline Cache Sample that demonstrates implementation of ISmoothStreamingCache is available on the IIS Website.

For documentation of the sample, see Cache Plug-in Implementation of ISmoothStreamingCache.

The following code shows an implementation of the EndRetrieve(IAsyncResult) method.

    public CacheResponse EndRetrieve(IAsyncResult ar)

        CacheResponse response = null;

        if (keyUrls.ContainsKey(((CacheAsyncResult)ar).strUrl))
            IsolatedStorageFile isoFileArea = IsolatedStorageFile.GetUserStoreForApplication();
            string filename = keyUrls[((CacheAsyncResult)ar).strUrl];

            if (!string.IsNullOrEmpty(filename) && isoFileArea.FileExists(filename))
                IsolatedStorageFileStream stream = 
                    isoFileArea.OpenFile(filename, System.IO.FileMode.Open, System.IO.FileAccess.Read);
                response = new CacheResponse(stream);                    

        if (response != null)
            return response;
            return response = new CacheResponse(0, null, null, null,
                System.Net.HttpStatusCode.NotFound, "Not Found", TimeManager.Now);


Supported in: 4

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.0