c#
====
[WebMethod]
public async static Task<string> 查詢Async()
{
using (var db = new Entities1())
{
var xxx =(await db.xxx.Where(a => ...).ToListAsync().ConfigureAwait(false)).Select(a => ...);
※加入 .ConfigureAwait(false) 避免無窮等待,原因可參考這篇,簡短說明參考:
To avoid performance degradation and possible dead-locks in ASP.NET or WPF applications (or any SynchronizationContext-dependent environment), you should always put ConfigureAwait(false) in your await statements:
javascript
====
$http.post('xxx.aspx/查詢Async', { })
.then(function (result) {
var newlist = JSON.parse(result.data.d.Result);
※回傳資料會放在Result裡面
aspx
====
<%@ Page Async="true"
沒有留言:
張貼留言