on 08-16-2005 4:15 PM
Hi,
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?
Thanks, cleared up all
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
What you observe is first of all a COM behavior (regardless which dev. language you use):
When you handle an event and in this handler call the COM interface in the other direction, the COM interface is unblocked and you will receive further events; you might even find your event handler getting called a second time(!) before you passed back control in your code when handling the first event!
I.e. you need to reflect this behavior in the design of your application by using kernel objects etc., but it will always be difficult.
Sorry for the bad news...
Regards,
Frank
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
110 | |
12 | |
11 | |
6 | |
5 | |
4 | |
4 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.