Spiga
Posts - 175, Articles - 14, Comments - 2601
Cnblogs
Dashboard
Login
Home
Contact
Gallery
RSS
Cat in dotNET
异步调用框架Async.Operation
2009-05-07 11:44 by Cat Chen, 230 visits,
收藏
,
编辑
Async
=
{
Operation:
function
()
{
var
callbackQueue
=
[];
this
.result
=
undefined;
this
.state
=
"running
"
;
this
.completed
=
false
;
this
.yield
=
function
(result)
{
var
self
=
this
;
setTimeout(
function
()
{
self.result
=
result;
self.state
=
"
completed
"
;
self.completed
=
true
;
while
(callbackQueue.length
>
0
)
{
var
callback
=
callbackQueue.shift();
callback(self.result);
}
}
,
1
);
return
this
;
}
;
this
.addCallback
=
function
(callback)
{
callbackQueue.push(callback);
if
(
this
.completed)
{
this
.yield(
this
.result);
}
return
this
;
}
;
}
}
;
绿色通道:
好文要顶
关注我
收藏该文
与我联系
注册用户登录后才能发表评论,请
登录
或
注册
,
返回博客园首页
。
首页
博问
闪存
新闻
园子
招聘
知识库
最新IT新闻
:
·
开心网否认无线业务裁员:仅为划分至各部门
·
谷歌钱包被曝存低级漏洞 或致用户资金被窃
·
摩托罗拉移动与苹果专利诉讼首次败诉
·
TomTom导航仪被用于设置保险费率
·
传原淘宝总裁孙彤宇重回阿里 或被委以重任
»
更多新闻...
最新知识库文章
:
·
高级编程语言的发展历程
·
如何学习一门新的编程语言?
·
学习不同编程语言的重要性
·
为什么我喜欢富于表达性的编程语言
·
计算机专业的女生为什么要学编程
»
更多知识库文章...
China-pub 2011秋季教材巡展
China-Pub 计算机绝版图书按需印刷服务
About
我的链接
我的标识
我的简历与作品
@CatChen
Cat in Chinese
Cat in English
Cat on Web Tech
订阅
版权许可
This work is licensed under a
Creative Commons License
.
昵称:
Cat Chen
园龄:
5年3个月
粉丝:
131
关注:
0
随笔分类
Rss
*Book Recommendation*(3)
Rss
*Comprehensive Understanding*(9)
Rss
*Most Practical*(9)
Rss
*Netcasts*(2)
Rss
*Random Clippings*(10)
Rss
*Resources*(8)
Rss
.NET Framework(14)
Rss
AJAX(46)
Rss
ASP.NET(68)
Rss
ASP.NET AJAX(24)
Rss
ASP.NET Futures(8)
Rss
C#(7)
Rss
CSS(14)
Rss
IE(2)
Rss
iPhone(8)
Rss
JavaScript(55)
Rss
LINQ(1)
Rss
Linq to Sql(2)
Rss
Linq to Xml(1)
Rss
Mac(1)
Rss
Node.js(1)
Rss
Rails(4)
Rss
Ruby(4)
Rss
Silverlight(7)
Rss
SQL(4)
Rss
Web(113)
Rss
WF(1)
Rss
Windows(1)
Rss
WPF(1)
Rss
XNA(1)
随笔档案
2012年1月(2)
2011年12月(3)
2011年8月(1)
2011年7月(1)
2011年5月(1)
2010年12月(2)
2010年11月(5)
2010年7月(3)
2010年5月(1)
2010年3月(1)
2010年2月(3)
2010年1月(1)
更多...
2009年12月(4)
2009年11月(5)
2009年10月(3)
2009年9月(1)
2009年8月(2)
2009年7月(3)
2009年6月(4)
2009年5月(4)
2009年4月(1)
2009年3月(2)
2008年12月(3)
2008年11月(2)
2008年10月(2)
2008年9月(2)
2008年4月(2)
2008年3月(5)
2008年2月(1)
2008年1月(7)
2007年12月(6)
2007年11月(4)
2007年10月(4)
2007年9月(1)
2007年8月(2)
2007年7月(3)
2007年6月(4)
2007年5月(4)
2007年4月(1)
2007年3月(5)
2007年2月(7)
2007年1月(3)
2006年12月(13)
2006年11月(11)
2006年10月(30)
推荐排行榜
阅读排行榜
我的链接
Rss
Cat in Chinese
Rss
Cat in English
我的标识
我的简历与作品