当前位置:网站首页>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边栏推荐
- Apache Web page security optimization
- Jd.com 2: how to prevent oversold in the deduction process of commodity inventory?
- 2022/02/13
- 返回二叉树中两个节点的最低公共祖先
- Qrcode: generate QR code from text
- Use UDP to send a JPEG image, and UPD will convert it into the mat format of OpenCV after receiving it
- Share the newly released web application development framework based on blazor Technology
- Hot knowledge of multithreading (I): introduction to ThreadLocal and underlying principles
- Dart series: collection of best practices
- Asemi rectifier bridge 2w10 parameters, 2w10 specifications, 2w10 characteristics
猜你喜欢

Flume configuration 4 - customize mysqlsource

Design and implementation of community hospital information system

This + closure + scope interview question

Pdf things
![ASP. Net core 6 framework unveiling example demonstration [01]: initial programming experience](/img/22/08617736a8b943bc9c254aac60c8cb.jpg)
ASP. Net core 6 framework unveiling example demonstration [01]: initial programming experience

Devtools的简单使用

Azkaban installation and deployment

Linux安装Redis

Sqoop命令

Avoid material "minefields"! Play with super high conversion rate
随机推荐
The phenomenology of crypto world: Pioneer entropy
El select, El option drop-down selection box
【LeetCode】110. Balanced binary tree (2 brushes of wrong questions)
Asp+access campus network goods trading platform
Spoon inserts and updates the Oracle database, and some prompts are inserted with errors. Assertion botch: negative time
The database and recharge are gone
Character painting, I use characters to draw a Bing Dwen Dwen
College Students' innovation project management system
问下,这个ADB mysql支持sqlserver吗?
Class inheritance in C #
When the low alcohol race track enters the reshuffle period, how can the new brand break the three major problems?
Utilisation simple de devtools
ASP. Net core 6 framework unveiling example demonstration [01]: initial programming experience
2.常见的请求方法
有个疑问 flink sql cdc 的话可以设置并行度么, 并行度大于1会有顺序问题吧?
【LeetCode】98. Verify the binary search tree (2 brushes of wrong questions)
有個疑問 flink sql cdc 的話可以設置並行度麼, 並行度大於1會有順序問題吧?
LeetCode 237. Delete nodes in the linked list
Structure of ViewModel
The latest blind box mall, which has been repaired very popular these days, has complete open source operation source code