[dba-VB] VB.Net - Proxy Class

Charlotte Foust cfoust at infostatsystems.com
Fri Jul 27 10:14:13 CDT 2007


We use a System.ComponentModel.backgroundworker for stuff like
this--progress bars, etc.  There is a System.ComponentModel delegate
called DoWorkEventHandler that may be what you're looking for.

Charlotte Foust 

-----Original Message-----
From: dba-vb-bounces at databaseadvisors.com
[mailto:dba-vb-bounces at databaseadvisors.com] On Behalf Of jwcolby
Sent: Friday, July 27, 2007 7:49 AM
To: dba-vb at databaseadvisors.com
Subject: [dba-VB] VB.Net - Proxy Class

I have a situation where I want to have a generic status form which
updates progress information for some very similar processes.  In all
cases a process class needs to raise events and the events need to be
sunk in the progress form.  Each event then updates one specific control
on the progress form.

Current file	

My problem is that AFAIK in order to sink events, an object has to be
dimmed WithEvents and the type of object has to be specified.  Thus the
progress form would have to be told in its header that it was working
with a specific class, and thus the progress form is no longer generic.
I know that I can not use events and simply have the class open an
instance of the progress form directly, and directly manipulate the
controls but I would prefer to have a loosely coupled interface in the
process class where it can just raise events and if there is anyone who
cares, it can process those events.

Can I use something like a proxy class where the proxy class knows about
process class and retransmits its events.  The progress form knows about
the proxy class.  Thus the progress form is loaded and passed in a proxy
That proxy class has been defined and hard coded to dim a specific
object which sources the events of interest?  

This seems like an inheritance thing for the proxy class.  Design a
ProgressProxy class which has code to source specific named events.
Create a clsProcessProxy which inherits the ProgressProxy class.  In
this class hard code the object which is the original event source.
Name this object a generic name so that the object itself can be
changed, but the event sinks never change and simply then call up to the
parent (inherited ProgressProxy) to retransmit the event.

clsProcess > clsProcessProxy inherits ProgressProxy > frmProgress (dims
a clsProcessProxy and is passed in an instance to set its local copy to)

Does any of this make sense?

John W. Colby
Colby Consulting

dba-VB mailing list
dba-VB at databaseadvisors.com

More information about the dba-VB mailing list