we are using C# and our AddOn uses the Event-system (MainClass.SAPApplication.ItemEvent) exceedingly. For this we use ONE delegate (because otherwise toggling the bubbleEvent does not stop the execution) and from there we push the events to the different objects.
We noticed that some Events reached our AddOn later then expected and sometimes even in between and after a while we saw (using System.AppDomain.GetCurrentThreadId()), that the Events are indeed coming from different threads.
There seems to be a thread-pool and the single Events will be sent along on different threads.
In short: This is disastrous. We rely on a certain order of events coming in and this does obviously not work well together with threading. We can't lock the Event-pushing because sometimes we generate Events on our own during the Event-consumption and locking will then lead to deadlocks.
Is this threading-behaviour intended? Is it a problem of C#? Can it be solved somehow?