ISmoothStreamingCache.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)

Syntax

'Declaration

Function EndRetrieve ( _
    ar As IAsyncResult _
) As CacheResponse
'Usage

Dim instance As ISmoothStreamingCache
Dim ar As IAsyncResult
Dim returnValue As CacheResponse

returnValue = instance.EndRetrieve(ar)
CacheResponse EndRetrieve(
    IAsyncResult ar
)
CacheResponse^ EndRetrieve(
    IAsyncResult^ ar
)
abstract EndRetrieve : 
        ar:IAsyncResult -> CacheResponse 
function EndRetrieve(
    ar : IAsyncResult
) : CacheResponse

Parameters

Return Value

Type: Microsoft.Web.Media.SmoothStreaming.CacheResponse
An IAsyncResult object.

Remarks

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.

Examples

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

    public CacheResponse EndRetrieve(IAsyncResult ar)
    {
        ar.AsyncWaitHandle.WaitOne();

        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;
        else
            return response = new CacheResponse(0, null, null, null,
                System.Net.HttpStatusCode.NotFound, "Not Found", TimeManager.Now);
    }

Version Information

Silverlight

Supported in: 5

Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

See Also

Reference

ISmoothStreamingCache Interface

Microsoft.Web.Media.SmoothStreaming Namespace