zoukankan      html  css  js  c++  java
  • 微软官方示例里的HTTPrequest借鉴

    try
    {
        HttpResponseMessage response = await httpClient.PostAsync(resourceAddress,
            new HttpStringContent(RequestBodyField.Text)).AsTask(cts.Token);
    
        await Helpers.DisplayTextResultAsync(response, OutputField, cts.Token);
    
        rootPage.NotifyUser("Completed", NotifyType.StatusMessage);
    }
    catch (TaskCanceledException)
    {
        rootPage.NotifyUser("Request canceled.", NotifyType.ErrorMessage);
    }
    catch (Exception ex)
    {
        rootPage.NotifyUser("Error: " + ex.Message, NotifyType.ErrorMessage);
    }
    finally
    {
        Helpers.ScenarioCompleted(StartButton, CancelButton);
    }
    

    还借用另外两个CS文件:Helpers.cs / PlugInFilter.cs

    但是在生成response时抛出exception

    HttpResponseMessage response = await httpClient.PostAsync(resourceAddress,
        new HttpStringContent(RequestBodyField.Text)).AsTask(cts.Token);
    

    09-25
    在前期需要先定义变量

    Helpers.CreateHttpClient(ref httpClient);
    cts = new CancellationTokenSource();
    
  • 相关阅读:
    hdu4291 A Short problem
    UVA
    HDU
    Be Geeks!
    HDU
    hdu6559 The Tower
    胜利大逃亡(续) + Maze
    Stealing Harry Potter's Precious
    hdu5172 GTY's gay friends
    Log Concave Sequences Gym
  • 原文地址:https://www.cnblogs.com/woodytian/p/4835468.html
Copyright © 2011-2022 走看看