这个异步 Lambda Cryptica 代码是否符合我的想法?
Action<SPItemEventProperties> deleteAction = DeleteWorkspace;
AsyncCallback deleteDone = deleteAction.EndInvoke;
SPSecurity.RunWithElevatedPrivileges(() => deleteAction.BeginInvoke(properties, deleteDone, null));
所以这应该异步调用DeleteWorkspace,然后在完成后调用EndInvoke,我写了它,但我不确定它会正常工作。 我逐步执行,它似乎可以工作,但语法让我自己重新猜测,因为我从未在网上看到过这样的操作...
评论?
Action<SPItemEventProperties> deleteAction = DeleteWorkspace;
AsyncCallback deleteDone = deleteAction.EndInvoke;
SPSecurity.RunWithElevatedPrivileges(() => deleteAction.BeginInvoke(properties, deleteDone, null));
So this is suppose to call DeleteWorkspace Asynchronously and then call EndInvoke when its done, I wrote it but I am not positive it will work properly. I stepped through and it appears to work but the syntax is making me second guess myself cause I have never seen it done like this on the net...
Comments?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
它应该可以工作,但要真正理解它,让我们假设它是这样写的:
请注意,在上面的代码中,看起来“完成”回调将立即超出范围。 但是,编译器将使用闭包捕获(关闭)它,以便在需要时可用。
It should work, but to really understand it let's pretend it were written like this:
Note that in the code above, it looks like the 'Done' callback will go out of scope right away. However, the compiler will capture (close over) it with a closure, so that it's available when needed.