问:关于Scoap,Compensation,Catch中的变量作用域!

xz_king 2007-05-14 09:49:37
流程
int g_i = 0;
Message msg;

receive(msg)
scoap
{
scoap
{
g_i=1;
}
Compensation1
{
g_i=2;
print2(g_i)
}
throw exprestion;
}
catch
{
call Compensation1
}
print1(g_i);

问题
按理说,g_i的赋值过程是
g_i=1
进行补偿
g_i=2

但为什么
print1(g_i)=1
print2(g_i)=2
呢。

这是别人问我的问题,自己也没解决!
...全文
285 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
upzone 2007-06-01
  • 打赏
  • 举报
回复
Inside a compensation block, all variables assume the values they had when the body of the scope committed. Note that the compensation block of a scope never runs immediately after its body completes; there is always intervening code. If any of that intervening code updates some outer-scope variables, and then the compensation block runs, those updates will not be seen inside the compensation block. Instead the variables will temporarily revert to the values they had at the time the scope which owns that compensation had committed.

补偿块的变量从body里继承过来,如果outscope更形了变量然后执行补偿块,,那么补偿块里看不到这些更新,而补偿块里的变量仍然是以前body里的变量

from:BizTalk SDK Document
xz_king 2007-05-14
  • 打赏
  • 举报
回复
have a look
http://blogs.msdn.com/richardbpi/archive/2006/12/06/transactions-and-compensation-using-biztalk-server.aspx
xz_king 2007-05-14
  • 打赏
  • 举报
回复
have a look
http://geekswithblogs.net/cyoung/articles/100424.aspx

241

社区成员

发帖
与我相关
我的任务
社区描述
企业开发 其他
社区管理员
  • 其他
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧