private static void TimeoutCallback(object context, bool timedOut)
 {
     DotNetUrlDownloader.DownloadState downloadState = (DotNetUrlDownloader.DownloadState)context;
     downloadState.UnregisterTimeout();
     if (timedOut)
     {
         downloadState.request.Abort();
     }
 }
        private static void FinishDownload(DotNetUrlDownloader.DownloadState state)
        {
            if (!state.downloadResult.succeeded && state.numRetriesLeft > 0)
            {
                state.numRetriesLeft--;
                DotNetUrlDownloader.Download(state);
                return;
            }
            List <DotNetUrlDownloader.DownloadResult> completedDownloads = state.downloader.m_completedDownloads;

            lock (completedDownloads)
            {
                state.downloader.m_completedDownloads.Add(state.downloadResult);
            }
        }
 private static void ResponseCallback(IAsyncResult ar)
 {
     DotNetUrlDownloader.DownloadState asyncState = (DotNetUrlDownloader.DownloadState)ar.AsyncState;
     try
     {
         WebResponse webResponse    = asyncState.request.EndGetResponse(ar);
         Stream      responseStream = webResponse.GetResponseStream();
         asyncState.responseStream = responseStream;
         asyncState.downloadResult.downloadData = new byte[checked ((IntPtr)webResponse.ContentLength)];
         responseStream.BeginRead(asyncState.readBuffer, 0, (int)asyncState.readBuffer.Length, new AsyncCallback(DotNetUrlDownloader.ReadCallback), asyncState);
     }
     catch (Exception exception)
     {
         DotNetUrlDownloader.FinishDownload(asyncState);
     }
 }
 private static void ResponseCallback(IAsyncResult ar)
 {
     DotNetUrlDownloader.DownloadState downloadState = (DotNetUrlDownloader.DownloadState)ar.get_AsyncState();
     try
     {
         WebRequest  request        = downloadState.request;
         WebResponse webResponse    = request.EndGetResponse(ar);
         Stream      responseStream = webResponse.GetResponseStream();
         downloadState.responseStream = responseStream;
         downloadState.downloadResult.downloadData = new byte[webResponse.get_ContentLength()];
         responseStream.BeginRead(downloadState.readBuffer, 0, downloadState.readBuffer.Length, new AsyncCallback(DotNetUrlDownloader.ReadCallback), downloadState);
     }
     catch (Exception)
     {
         DotNetUrlDownloader.FinishDownload(downloadState);
     }
 }
 private static void Download(DotNetUrlDownloader.DownloadState state)
 {
     try
     {
         IAsyncResult asyncResult = state.request.BeginGetResponse(new AsyncCallback(DotNetUrlDownloader.ResponseCallback), state);
         int          num         = state.timeoutMs;
         if (num < 0)
         {
             num = -1;
         }
         state.timeoutWatchHandle = asyncResult.get_AsyncWaitHandle();
         state.timeoutWaitHandle  = ThreadPool.RegisterWaitForSingleObject(state.timeoutWatchHandle, new WaitOrTimerCallback(DotNetUrlDownloader.TimeoutCallback), state, num, true);
     }
     catch (Exception)
     {
         DotNetUrlDownloader.FinishDownload(state);
     }
 }
        public void Download(string url, UrlDownloadCompletedCallback cb, UrlDownloaderConfig config)
        {
            WebRequest webRequest = WebRequest.Create(url);

            DotNetUrlDownloader.DownloadResult downloadResult = new DotNetUrlDownloader.DownloadResult()
            {
                callback = cb
            };
            DotNetUrlDownloader.DownloadState downloadState = new DotNetUrlDownloader.DownloadState()
            {
                downloader     = this,
                host           = url,
                downloadResult = downloadResult,
                request        = webRequest,
                numRetriesLeft = config.numRetries,
                timeoutMs      = config.timeoutMs
            };
            DotNetUrlDownloader.Download(downloadState);
        }
 private static void FinishDownload(DotNetUrlDownloader.DownloadState state)
 {
     //
     // Current member / type: System.Void bgs.DotNetUrlDownloader::FinishDownload(bgs.DotNetUrlDownloader/DownloadState)
     // File path: C:\apktool\WoW Companion_2.0.27325\assets\bin\Data\Managed\Assembly-CSharp.dll
     //
     // Product version: 2018.2.803.0
     // Exception in: System.Void FinishDownload(bgs.DotNetUrlDownloader/DownloadState)
     //
     // La référence d'objet n'est pas définie à une instance d'un objet.
     //    à ž..Žƒ() dans C:\DeveloperTooling_JD_Agent1\_work\15\s\OpenSource\Cecil.Decompiler\Steps\RebuildLockStatements.cs:ligne 93
     //    à ž..”(•Ÿ ) dans C:\DeveloperTooling_JD_Agent1\_work\15\s\OpenSource\Cecil.Decompiler\Steps\RebuildLockStatements.cs:ligne 24
     //    à †”.–.Visit(ICodeNode ) dans C:\DeveloperTooling_JD_Agent1\_work\15\s\OpenSource\Cecil.Decompiler\Ast\BaseCodeVisitor.cs:ligne 69
     //    à ž..œ(DecompilationContext ™, •Ÿ €–) dans C:\DeveloperTooling_JD_Agent1\_work\15\s\OpenSource\Cecil.Decompiler\Steps\RebuildLockStatements.cs:ligne 19
     //    à ‚–.™“.(MethodBody €–, •Ÿ Ÿ, ILanguage ) dans C:\DeveloperTooling_JD_Agent1\_work\15\s\OpenSource\Cecil.Decompiler\Decompiler\DecompilationPipeline.cs:ligne 88
     //    à ‚–.™“.‹(MethodBody €–, ILanguage ) dans C:\DeveloperTooling_JD_Agent1\_work\15\s\OpenSource\Cecil.Decompiler\Decompiler\DecompilationPipeline.cs:ligne 70
     //    à Telerik.JustDecompiler.Decompiler.Extensions.›“(™“ œ“, ILanguage , MethodBody €–, DecompilationContext& ™) dans C:\DeveloperTooling_JD_Agent1\_work\15\s\OpenSource\Cecil.Decompiler\Decompiler\Extensions.cs:ligne 95
     //    à Telerik.JustDecompiler.Decompiler.Extensions.š“(MethodBody €–, ILanguage , DecompilationContext& ™,  œ–) dans C:\DeveloperTooling_JD_Agent1\_work\15\s\OpenSource\Cecil.Decompiler\Decompiler\Extensions.cs:ligne 58
     //    à ——.ƒ˜.—(ILanguage , MethodDefinition €,  œ–) dans C:\DeveloperTooling_JD_Agent1\_work\15\s\OpenSource\Cecil.Decompiler\Decompiler\WriterContextServices\BaseWriterContextService.cs:ligne 117
     //
     // mailto: [email protected]
 }