Exemple #1
0
 /// <summary>
 ///  worker method for the query case
 /// </summary>
 /// <param name="data"></param>
 /// <param name="asyncOp"></param>
 /// <param name="completionMethodDelegate"></param>
 /// <returns></returns>
 private void AsyncQueryWorker(AsyncQueryData data, AsyncOperation asyncOp, SendOrPostCallback completionMethodDelegate)
 {
     try
     {
         long contentLength;
         using (var responseStream = Query(data.UriToUse, data.Modified, null, out contentLength))
         {
             HandleResponseStream(data, responseStream, contentLength);
         }
     }
     catch (Exception e)
     {
         data.Exception = e;
     }
     completionMethodDelegate(data);
 }
Exemple #2
0
        /// <summary>
        /// the basic interface as an async version. This call will return directly
        /// and you need to rely on the events fired to figure out what happened.
        /// </summary>
        /// <param name="queryUri">the Uri to Query</param>
        /// <param name="ifModifiedSince">The ifmodifiedsince date, use DateTime.MinValue if you want everything</param>
        /// <param name="doParse">if true, returns a feed, else a stream</param>
        /// <param name="userData">The userData token. this must be unique if you make several async requests at once</param>
        /// <returns>nothing</returns>
        private void QueryAsync(Uri queryUri, DateTime ifModifiedSince, bool doParse, Object userData)
        {
            AsyncOperation asyncOp = AsyncOperationManager.CreateOperation(userData);
            AsyncQueryData data    = new AsyncQueryData(queryUri, ifModifiedSince, doParse, asyncOp, userData, this.ProgressReportDelegate);

            AddUserDataToDictionary(userData, asyncOp);

            // Start the asynchronous operation.
            WorkerQueryEventHandler workerDelegate = new WorkerQueryEventHandler(AsyncQueryWorker);

            workerDelegate.BeginInvoke(
                data,
                asyncOp,
                this.CompletionMethodDelegate,
                null,
                null);
        }