|Works With||IIS 7, IIS 7.5|
|Updated on||September 29, 2010|
|Uploaded by||mike dodaro|
On the first pass, before the cache has any data, the calls to BeginRetrieve and EndRetrieve return a null CascheResponse object. The application will then call BeginPersist to cache the data for future use as needed for the off-line scenario. The BeginPersist method parses the data returned from the server. If there is enough available storage, the data is stored in IsolatedStorage. When the data has been successfully parsed and persisted, EndPersist returns true.
If BeginPersist and EndPersist have previously run successfully, the cache will already have the required data on a new data request. Instead of making a call to the IIS Server, BeginRetrieve will process, and EndRetrieve will return, a SmoothStreamingAsyncResult that contains a non-null CacheResponse object to be played back by the application instance of SmoothStreamingMediaElement.
As demonstrated in the sample, EndRetrieve must wait for BeginRetrieve to complete by using the ar.AsyncWaitHandle.WaitOne method, and, similarly, EndPersist should wait for BeginPersist to complete.