[dba-VB] Background worker threads

Charlotte Foust cfoust at infostatsystems.com
Wed Apr 30 10:19:03 CDT 2008


You can create your own events with whatever parameters you want and
raise those.  Just Dim Public Event Whatever(parameter)  Then raise it
as needed.

Charlotte Foust 

-----Original Message-----
From: dba-vb-bounces at databaseadvisors.com
[mailto:dba-vb-bounces at databaseadvisors.com] On Behalf Of jwcolby
Sent: Wednesday, April 30, 2008 6:10 AM
To: VBA
Subject: [dba-VB] Background worker threads

I am new to this worker thread thing.  I know that the worker can report
status but it does so by raising an event and passing a single value (or
object) to the event handler.

I currently have a user form that in the past I simply raised an event
from my class and the form sank the event and updated a text box.  Which
event I raised determined which text box got updated.

Now my thread can't raise that same event(s) AFAICT because the event
sink writes to the text box on the form.  However the progress changed
event that it can raise is limited to a single parameter, but I need to
update several different status boxes on the main form.

My thought is to create a status class which has a couple of fields, the
name of the control to update and the data to put in the control.  The
worker thread would then instantiate one of these status classes, fill
it in, and raise its ProgressChanged event passing out the status class
instance.  The progressChanged sink receives that status class instance
and processes it.  It can use the control name to raise the correct
event, passing the value to be stuffed into the control.

Does that make sense or is there a simpler way?


--
John W. Colby
www.ColbyConsulting.com

_______________________________________________
dba-VB mailing list
dba-VB at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/dba-vb
http://www.databaseadvisors.com





More information about the dba-VB mailing list