示例#1
0
        private async Task CheckLink(BindableLinkDescription arg, CancellationToken cancelToken)
        {
            try
            {
                var res = await LinkChecker.CheckLink(arg.OriginalLink, cancelToken).ConfigureAwait(false);

                // access the binding on the UI thread
                await this.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
                {
                    arg.HttpStatus        = (int)res.HttpStatusCode;
                    arg.LinkAfterRedirect = res.NewLink;
                    arg.Result            = res.Summary;
                    if (res.Summary == LinkCheckSummary.SimpleChange)
                    {
                        arg.SelectForUpdate = true;
                    }
                    else if (res.Summary == LinkCheckSummary.Error ||
                             res.Summary == LinkCheckSummary.NotFound)
                    {
                        arg.SelectForInvalidMark = true;
                    }
                });
            }
            catch (Exception ex)
            {
                Logger.Log(LogLevel.Error, nameof(CheckLink), "Error checking link: " + arg?.OriginalLink, ex);
            }
        }
        private static async Task CheckLink(BindableLinkDescription arg, CancellationToken cancelToken)
        {
            var res = await LinkChecker.CheckLink(arg.OriginalLink, cancelToken).ConfigureAwait(false);

            arg.HttpStatus        = (int)res.HttpStatusCode;
            arg.LinkAfterRedirect = res.NewLink;
            arg.Result            = res.Summary;
            if (res.Summary == LinkCheckSummary.SimpleChange)
            {
                arg.SelectForUpdate = true;
            }
            else if (res.Summary == LinkCheckSummary.Error ||
                     res.Summary == LinkCheckSummary.NotFound)
            {
                arg.SelectForInvalidMark = true;
            }
        }