EndPersist Method

A AsyncCallback delegate method to complete the operation started by the BeginPersist method.

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

bool EndPersist(
	IAsyncResult ar
)

Parameters

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

Return Value

Type: System..::..Boolean
Returns true if successful, otherwise false.

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 EndPersist(IAsyncResult) method.

    public bool EndPersist(IAsyncResult ar)
    {
        ar.AsyncWaitHandle.WaitOne();

        if (((CacheAsyncResult)ar).Result != null)
        {
            IsolatedStorageFile isoFileArea = IsolatedStorageFile.GetUserStoreForApplication();

            if (((CacheResponse)(((CacheAsyncResult)ar).Result)).Response.Length < isoFileArea.AvailableFreeSpace)
            {
                string fileGuid = Guid.NewGuid().ToString();
 
                if (!keyUrls.ContainsValue(fileGuid) && !keyUrls.ContainsKey(((CacheAsyncResult)ar).strUrl))
                {
                        
                    IsolatedStorageFileStream isoFile = isoFileArea.CreateFile(fileGuid);

                    ((CacheResponse)(((CacheAsyncResult)ar).Result)).WriteTo(isoFile);
                    isoFile.Close(); 

                    keyUrls.Add(((CacheAsyncResult)ar).strUrl, fileGuid);
                    // Save key/value pairs for playback after application restarts.
                    IsolatedStorageSettings.ApplicationSettings.Add(((CacheAsyncResult)ar).strUrl, fileGuid);
                    IsolatedStorageSettings.ApplicationSettings.Save();

                    return true;
                }
            }
        }
        return false;
    }


Silverlight

Supported in: 4

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.0

Show: