[dba-VB] Threads and stuff

Charlotte Foust cfoust at infostatsystems.com
Fri Oct 16 15:00:20 CDT 2009


Are you declaring the properties shared?

Charlotte Foust 

-----Original Message-----
From: dba-vb-bounces at databaseadvisors.com
[mailto:dba-vb-bounces at databaseadvisors.com] On Behalf Of jwcolby
Sent: Friday, October 16, 2009 11:27 AM
To: VBA
Subject: [dba-VB] Threads and stuff

I am trying to figure out threads.  My biggest question has to do with
static declarations.  It appears that the thread initialization requires
a static method to call.

I have a class which will start an external program / process.  This
process hangs the thread it runs on until the external program closes or
the ProcessStartInfo times out at which point ProcessStartInfo shuts
down the external process.  It is this thing that I am trying to do in a
thread.  I thought I would build a class, the class would contain all
the thread stuff, set up the thread, start the thread etc.  Thus I could
simply instantiate the class, pass in the program to run, and call a
start() method to cause the class' own thread to run the process.  I got
all of that working but... the static function that the thread runs is
not visible from outside of the class if the class is instantiated.
That was unexpected.  I understand that a static function is designed to
allow calling it without instantiating the class, however it makes sense
to me to instantiate the class once for each program instance I want to
run.  The thread that runs the program instance belongs to the class
instance that opens the program instance.
Am I deluded?
Anyway, because the class method that the thread runs has to be static,
all of the class properties (name of the program to open etc) have to be
static.  I really want to initialize the class and manually call the
same function that the thread will call but it seems that static and
non-static cannot talk to each other.  IOW I had to copy and paste the
static method to another non-static method and call the non-static
method from the calling class.  Even inside of my class I couldn't call
the non-static method from inside of the static method.  Every property
and method reference from inside of the static method had to be declared
static as well.

--
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