我用c#开发的Windows服务中有一个异步方法,如下所示:
<?php
header('Access-Control-Allow-Origin: https://example1.com');
header('Access-Control-Allow-Credentials: true');
header('Access-Control-Allow-Headers: Content-Type, Content-Range, Content-Disposition, Content-Description');
require 'c.upload.php';
$tsUpload = new tsUpload();
echo $tsUpload['response']; //It have to respond a message like Uploaded Image or Image cannot Upload, not the message that I receive on the developer console.
在执行此操作时,有时会出现以下异常:public async Task<bool> SomeMethod()
{
//some logic
HttpResponseMessage response = null;
HttpRequestMessage requestMessage = new HttpRequestMessage(HttpMethod.Get, "someValue");
response = await HttpRequestAsync(requestMessage);
}
public async Task<HttpResponseMessage> HttpRequestAsync(HttpRequestMessage httpRequest)
{
response = await client.SendAsync(httpRequest);
return response;
}
此请求在服务中被多次调用,但我仅一次或两次收到此异常。对于其余的呼叫,它毫无例外地工作正常。
我用过:
System.Threading.Tasks.TaskCanceledException: A task was canceled.
这将等待30分钟,并在30分钟后引发异常。
任何人都可以帮助我了解可能是什么问题以及如何解决该问题。非常感谢!