我在一本书上看到关于什么时候不易使用delegate时看到这样一段描述,不太理解,发上来麻烦大家帮我看看,最好能举例解释一下。
In some cases,delegates and interfaces can achieve a degree of polymorphism in your code and provide a means to receieve callback notifications from a method. If performance is critical, consider defining and using an interface intead of a delegate.由于公司给的书都是原版的,所以把原文贴上来以免我理解错误。我大体理解为“在有些情况下两者都可以实现多态。如果要实现的行为只是做鉴别,考虑使用接口”。我不明白的是什么是critical performance?另外,在多线程环境下如何使用代理可以避免线程冲突?希望大家给支招。

解决方案 »

  1.   

    In some cases,delegates and interfaces can achieve a degree of polymorphism in your code and provide a means to receieve callback notifications from a method. If performance is critical, consider defining and using an interface intead of a delegate
    在一些情况下,委托和接口可以实现多态性,并提供从方法中得到回调通知。如果性能是摆在重要位置的话,优先考虑使用接口。
      

  2.   

    http://www.yoda.arachsys.com/csharp/threads/给你一个网址研究吧。