コード例 #1
0
        private async Task <PPError> FinishStreamingToFileAsyncCore(MessageLoop messageLoop = null)
        {
            var tcs = new TaskCompletionSource <PPError>();
            EventHandler <PPError> handler = (s, e) => { tcs.TrySetResult(e); };

            try
            {
                HandleFinishStreamingToFile += handler;

                if (MessageLoop == null && messageLoop == null)
                {
                    FinishStreamingToFile();
                }
                else
                {
                    Action <PPError> action = new Action <PPError>((e) =>
                    {
                        var result = (PPError)PPBURLLoader.FinishStreamingToFile(this, new BlockUntilComplete());
                        tcs.TrySetResult(result);
                    }
                                                                   );
                    InvokeHelper(action, messageLoop);
                }
                return(await tcs.Task);
            }
            catch (Exception exc)
            {
                Console.WriteLine(exc.Message);
                tcs.SetException(exc);
                return(PPError.Aborted);
            }
            finally
            {
                HandleFinishStreamingToFile -= handler;
            }
        }
コード例 #2
0
 /// <summary>
 /// This function is used to wait for the response body to be completely
 /// downloaded to the file provided by the GetBodyAsFileRef() in the current
 /// <code>URLResponseInfo</code>. This function is only used if
 /// <code>StreamToFile</code> was set on the <code>URLRequestInfo</code> passed to Open().
 /// </summary>
 /// <returns>Number of bytes read or an error code</returns>
 public PPError FinishStreamingToFile()
 => (PPError)PPBURLLoader.FinishStreamingToFile(this, new CompletionCallback(OnFinishStreamingToFile));