public async Task <System.Drawing.Image> CreateImageAsync(string url) { System.Drawing.Image img = null; try { using (var wc = new WebClientEx()) { wc.Headers.Add(HttpRequestHeader.UserAgent, Props.UserAgent); wc.Proxy = null; wc.timeout = 30000; using (var fs = await wc.OpenReadTaskAsync(url).Timeout(wc.timeout)) { img = System.Drawing.Image.FromStream(fs); } } } catch (WebException Ex) { if (Ex.Status == WebExceptionStatus.ProtocolError) { var errres = (HttpWebResponse)Ex.Response; if (errres != null) { if (errres.StatusCode == HttpStatusCode.NotFound) { using (var fs = new FileStream(Props.GetDefaultThumbnail("comm"), FileMode.Open, FileAccess.Read)) { img = System.Drawing.Image.FromStream(fs); } return(img); } } } DebugWrite.WriteWebln(nameof(CreateImageAsync), Ex); return(img); } catch (Exception Ex) //その他のエラー { DebugWrite.Writeln(nameof(CreateImageAsync), Ex); return(img); } return(img); }