VB 2008 - advanced language

  • Thread starter Thread starter Gilbert Tordeur
  • Start date Start date
G

Gilbert Tordeur

Hi

I have written a user Namespace and compiled it into a dll. This dll is used
by many programs in the company (Add Reference...).

I do not know how to do this : I would like something like a user exit in
some methods of this dll. That means that, when the dll executes its code,
sometimes it should give control back to the codes that invoked it to
execute some optional additional coding, and than continue normally its own
coding.

I have thought to use Partial Class, but I am not familiar with it, and I
think it is not possible with a separate dll. Perhaps a Raise Event ? But
does this event interrupt the procedure, or is the event executed only when
the dll has finished, which should be too late ?

Any advice will be welcome.

Thank you,
Gilbert
 
There are a number of ways you could do this. It seems to me that the issue
will be the relationship between this 'additional work' and the reason for
calling into that class. If this additional work is quite independent of
the processing flow - for instance, the processing in the DLL has indicated
that a GUI element needs to be updated - then using an event is an
appropriate way to do it. You may be able to set up the event so that the
event argument indicates what needs to be done, and only one event needs to
be defined for all of those methods. This will simplify the calling code.

If there is some connection between this additional work and the processing
associated with calling the method, then you have to consider the sequence.
For instance, if the interpretation of a result returned from the method is
dependant on this additional processing, you need to ensure that the
additional processing is completed before the method finishes, and raising
an event will not ensure this. A common procedure in this case is to
provide a 'test' function for the method. This test function returns a value
indicating whether the additional work is needed or not. If it is not
needed, the method is called imemdiately - if it is needed the additional
work is done and then the method is called. This option is also suitable for
cases where the calling function may know that the additional processing
will not be needed - it can call the method directly and skip the testing.

Note that partial classes are a way of arranging you coding elements amongst
the source files. While it may be convenient to use partial classes in this
context, they are not actually connected with what you are trying to
achieve.
 
Back
Top