C# event handing in single threaded applications
I have a single threaded C# assembly (my client) that subscribes to multiple events using the same event handler (a short print statement). The emitter of the events (the server) is multitreaded and therefore could fire two events simulatiously at my single threaded client.
How does the .NET platform handle this? Does it queue the events? Does it drop an event that can't be processed because the event hander is aready busy?
Background
I asked a previous question but judging by the clarifiation I needed to add I think I could do a much better job of abstracting my question to make it more general and useful to others.
Events in C# and .NET don't naturally know about threads at all. They're just an extra encapsulation layer for delegates, basically. The handlers will be called on whichever thread the "event raiser" chooses to use. It could decide to fire each event handler on a separate thread... or it could use one separate thread to calls all handlers, one after another... or it could do that synchronously within its own "normal" thread.
链接地址: http://www.djcxy.com/p/68068.html上一篇: c#事件执行是线程安全的?
下一篇: C#事件处理单线程应用程序