J
Jonathan
Hi all,
I have an application separated into visual, logic and data components
(c# dlls).
UserControl.dll
================
The visual component is a user control which implements an event sink
raised by the hosting application.
This sink is provided with application data via a parameter. The data
may not necessarily change between events.
Logic.dll
==========
The logic layer contains custom a business entity which maintains the
application data state. It can therefore determine when something has
changed.
It is "refreshed" via a call from the UserControl within its event handler.
If the state changes it is required to grab more information from a
database via a data layer.
Once this has been done, it signals the UserControl via an event that
new data has been obtained which needs displaying.
Data.dll
========
The data layer contains simple code to grab data from a database and,
once done, raises an event to which the Logic.dll subscribes.
This all works - but not in the way i had intended.
I (incorrectly) assumed that the UserControl would call a method in the
Logic.dll to refresh its data and return from this immediately to
service the UI and keep things responsive.
What actually happens is the call doesn't return until all subsequent
calls have completed (from the Logic.dll to Data.dll). Things are
happening synchronously and I might as well wait for the method calls to
complete instead of subscribing to and raising events.
I have considered a couple of ways to redesign to use aynchronous calls
(BeginInvoke/EndInvoke) either with a callback or no callback but I am
not sure whether this is the best or only way to address this.
If you have any guidance regarding best practices in this area I would
be grateful for your input.
Regards
Jon
I have an application separated into visual, logic and data components
(c# dlls).
UserControl.dll
================
The visual component is a user control which implements an event sink
raised by the hosting application.
This sink is provided with application data via a parameter. The data
may not necessarily change between events.
Logic.dll
==========
The logic layer contains custom a business entity which maintains the
application data state. It can therefore determine when something has
changed.
It is "refreshed" via a call from the UserControl within its event handler.
If the state changes it is required to grab more information from a
database via a data layer.
Once this has been done, it signals the UserControl via an event that
new data has been obtained which needs displaying.
Data.dll
========
The data layer contains simple code to grab data from a database and,
once done, raises an event to which the Logic.dll subscribes.
This all works - but not in the way i had intended.
I (incorrectly) assumed that the UserControl would call a method in the
Logic.dll to refresh its data and return from this immediately to
service the UI and keep things responsive.
What actually happens is the call doesn't return until all subsequent
calls have completed (from the Logic.dll to Data.dll). Things are
happening synchronously and I might as well wait for the method calls to
complete instead of subscribing to and raising events.
I have considered a couple of ways to redesign to use aynchronous calls
(BeginInvoke/EndInvoke) either with a callback or no callback but I am
not sure whether this is the best or only way to address this.
If you have any guidance regarding best practices in this area I would
be grateful for your input.
Regards
Jon