0
public class HomeController : Controller
{
public ActionResult Index()
{
var t1= Test1().Result;
return View();
}
private async Task<HttpResponseMessage> Test1()
{
string strUrl = "http://localhost:52033/api/values";
var instanceClient = new HttpClient();
var requestMessage = new HttpRequestMessage(HttpMethod.Get, strUrl);
var httpRespons = await instanceClient.SendAsync(requestMessage);
return httpRespons;
}
}
当我在名为Test1的Index Action中调用Test1()时。结果;当前线程死锁程序会发生无响应,不要带结果调用后缀可以正常运行!在MVC操作中调用任务方法,但当前线程被锁定
这是个问题吗? – ElefantPhace 2013-03-22 03:48:35
总之,你想要发生什么? – 2013-03-28 05:07:33