开发者

Timer Vs Event: which one is preferable for Asynchronous processing?

开发者 https://www.devze.com 2023-01-15 04:57 出处:网络
Ours is a huge project. I need to call certain functions i开发者_StackOverflow社区n my code asynchronously to avoid some circular function calls. Upon receiving a specific input, I can call my functio

Ours is a huge project. I need to call certain functions i开发者_StackOverflow社区n my code asynchronously to avoid some circular function calls. Upon receiving a specific input, I can call my function asynchronously either by using Event or Timer.

Which way is preferable considering Performance ?

Sending events to Event manager and handling them with an Event handler ? Or

Starting a timer and provide timeout handler ?


For pure performance, event-driven model will be better. Use timers only if you cannot rely on one or more of your events to get set in a timely way by the worker code, and so need a backup means by which to continue processing. This may be the case if your worker code makes external calls to a database or other remote service whose reliability or performance is unproven.

0

精彩评论

暂无评论...
验证码 换一张
取 消