public async Task<byte[]> DownloadAsync(string url, IDictionary<string, string> headers, string method)
 {
     using (var client = new CustomWebClient())
     {
         SubscribeToDownloadEvents(client);
         if (headers != null)
         {
             foreach (var header in headers)
                 client.Headers[header.Key] = header.Value;
         }
         
         var result = await client.DownloadDataTaskAsync(url);
         UnsubscribeFromDownloadEvents(client);
         return result;
         
     }
 }
        public async Task <byte[]> DownloadAsync(string url, IDictionary <string, string> headers, string method)
        {
            using (var client = new CustomWebClient())
            {
                SubscribeToDownloadEvents(client);
                if (headers != null)
                {
                    foreach (var header in headers)
                    {
                        client.Headers[header.Key] = header.Value;
                    }
                }

                var result = await client.DownloadDataTaskAsync(url);

                UnsubscribeFromDownloadEvents(client);
                return(result);
            }
        }