当前位置:网站首页>Performance of calling delegates vs methods
Performance of calling delegates vs methods
2022-07-05 03:03:00 【fyin1314】
problem :
Following this question - Pass Method as Parameter using C# and some of my personal experience I'd like to know a little more about the performance of calling a delegate vs just calling a method in C#. The next question - Use C# Pass the method as an argument , And some of my personal experience , I want to know more about the performance of invoking delegates rather than just using C# Performance of calling methods .
Although delegates are extremely convenient, I had an app that did lots of callbacks via delegates and when we rewrote this to use callback interfaces we got an order of magnitude speed improvement. Although delegation is very convenient , But I have an application that makes many callbacks through delegates , When we rewrite the program to use the callback interface , The speed has been improved .This was with .NET 2.0 so I'm not sure how things have changed with 3 and 4. This is a .NET 2.0 Version of , So I'm not sure 3 and 4 The change of .
How are calls to delegates handled internally in the compiler/CLR and how does this affect performance of method calls? How to use the compiler / CLR Internal processing calls to delegates , How does this affect the performance of method calls ?
EDIT - To clarify what I mean by delegates vs callback interfaces. edit - To clarify, I mean delegate and callback interfaces .
For asynchronous calls my class could provide an OnComplete event and associated delegate which the caller could subscribe to. For asynchronous calls , My class can provide OnComplete Events and associated delegates that the caller can subscribe to .
Alternatively I could create an ICallback interface with an OnComplete method that the caller implements and then registers itself with the class that will then call that method on completion (ie the way Java handles these things). perhaps , I can implement it with the caller OnComplete Method to create a ICallback Interface , Then register yourself with this class , This class will call this method when it is finished ( namely Java The way to deal with these things ).
Solution :
Reference resources : https://stackoom.com/en/question/8joV边栏推荐
- [micro service SCG] 33 usages of filters
- Sqoop command
- The perfect car for successful people: BMW X7! Superior performance, excellent comfort and safety
- Pat grade a 1119 pre- and post order traversals (30 points)
- Utilisation simple de devtools
- Tiny series rendering tutorial
- 1. Five layer network model
- The phenomenology of crypto world: Pioneer entropy
- Ubantu disk expansion (VMware)
- LeetCode 234. Palindrome linked list
猜你喜欢

The perfect car for successful people: BMW X7! Superior performance, excellent comfort and safety

Azkaban overview

Machine learning experiment report 1 - linear model, decision tree, neural network part

Hot knowledge of multithreading (I): introduction to ThreadLocal and underlying principles

Class inheritance in C #

The perfect car for successful people: BMW X7! Superior performance, excellent comfort and safety

Devtools的简单使用

Asemi rectifier bridge 2w10 parameters, 2w10 specifications, 2w10 characteristics

单项框 复选框

Voice chip wt2003h4 B008 single chip to realize the quick design of intelligent doorbell scheme
随机推荐
Design and practice of kubernetes cluster and application monitoring scheme
Sqoop命令
Utilisation simple de devtools
2021 Li Hongyi machine learning (2): pytorch
040. (2.9) relieved
Logstash、Fluentd、Fluent Bit、Vector? How to choose the appropriate open source log collector
Acwing第 58 场周赛【完结】
qrcode:将文本生成二维码
返回二叉树中两个节点的最低公共祖先
Design and implementation of community hospital information system
Class inheritance in C #
Usage scenarios and solutions of ledger sharing
el-select,el-option下拉选择框
tuple and point
Design and implementation of campus epidemic prevention and control system based on SSM
2021 Li Hongyi machine learning (1): basic concepts
为什么腾讯阿里等互联网大厂诞生的好产品越来越少?
Devtools的簡單使用
Avoid material "minefields"! Play with super high conversion rate
The perfect car for successful people: BMW X7! Superior performance, excellent comfort and safety