ブラウザのデバッグツールを使用し、PageMethods.GetCaseListで使用される自動生成コードを調べて、ブロッキングの代わりに非同期のajax呼び出しで呼び出しを模倣します。
PageMethodsラッパーは便宜上のものですが、コードは通常かなり醜いです。 $ .ajaxまたはネイティブXmlHttpRequestを使用すると、いつでも手動で自分自身を呼び出すことができます。
async = true;
複数の呼び出しを行う場合、ASP.NETセッションでブロックが行われている可能性があります。
function get_case_list_data(count, max_id) {
console.log("before call");
PageMethods.GetCaseList(count, max_id, uid, is_agent, got_case_list_data, OnFailure);
console.log("after call");
}
function got_case_list_data(){
console.log("in PageMethod success");
// -- updated --
// this could be blocking the call to/from other 2 second timer
// JS is single thread, so window.timeout and ajax callbacks will
// wait until the function is exited
// -- end update--
console.log("end of PageMethod success");
}
ブロックしているかを決定するためにはJavaScriptのメソッド内のアラートを使用するかにconsole.log - updated--
asp.netセッションを設定するスレッドを同期う排他セッションロックを削除READONLYする
したがって、基本的に呼び出しは非同期ではありませんか? –
PageMethodコールの前、成功したコールバック内、およびアラートを使用してこれをテストできます。 Googleの「aysnc PageMethods」はデフォルトではaysncと思われますので、同期化するには更新が必要です。いずれにしても、このブログにはあなたを始められる良いコンテンツがいくつかあります。 http://abhijit-j-shetty.blogspot.com/2011/04/aspnet-ajax-calling-pagemethods.html – Steve
$ ajaxをasync = trueで試してみました。同じ結果 –