threading question 
Author Message
 threading question

I've read through quite a few books on ActiveX dlls and exes, the threading
models, and everything that goes with it.  However I can't seem to find a
book which will fully explain the topic in detail, thus I have a question.

I have a standard exe project that I would like to be able to run multiple
functions at once.  For instance, I have two buttons on a form and each
button starts a search for a file in some dir.  I want the user to be able
to push both of these buttons and the searches would happen concurrently.  I
am thinking of having an activex dll which will do the searching and having
that dll run apartment threading.  This should allow me to create an object
of this dll for each search, each object on its own thread, doing its search
on its own thread concurrently.

However I don't think this is correct.  I can't seem to find any examples or
articles on this topic exactly.  If somebody could enlighten me I would
greatly appreciate it.

james



Thu, 20 Nov 2003 02:25:36 GMT  
 threading question
It can't be done from inside the same form...

Put each piece of code in a diferent module and
call which ever piece of code from a different button
(the buttons may need to be on different forms if
you don't use DoEvents)

Untested but should do the trick...

D.


Quote:
> I've read through quite a few books on ActiveX dlls and exes, the
threading
> models, and everything that goes with it.  However I can't seem to find a
> book which will fully explain the topic in detail, thus I have a question.

> I have a standard exe project that I would like to be able to run multiple
> functions at once.  For instance, I have two buttons on a form and each
> button starts a search for a file in some dir.  I want the user to be able
> to push both of these buttons and the searches would happen concurrently.
I
> am thinking of having an activex dll which will do the searching and
having
> that dll run apartment threading.  This should allow me to create an
object
> of this dll for each search, each object on its own thread, doing its
search
> on its own thread concurrently.

> However I don't think this is correct.  I can't seem to find any examples
or
> articles on this topic exactly.  If somebody could enlighten me I would
> greatly appreciate it.

> james



Thu, 20 Nov 2003 03:01:42 GMT  
 threading question
Hi James,

ActiveX DLLs run in the same thread as the calling application so you cannot use
these to process several tasks from the same application in a separate threads.
To do background processing in separate threads you should use an ActiveX EXE.
The "Coffee" project in MSDN shows you how this can be done, and any good book
on the subject (e.g. Dan Appleman's "Developing Com/ActiveX Components in VB6")
will also give you examples.

You should be aware (and perhaps you already are) that, with a single processor,
carrying out tasks concurrently will not get the overall job done faster than
having them carried out one after the other.  The processor simply shares time
among the tasks and thus each will be slower than if carried out separately.
However, concurrent processing will reduce the delay that a short task might
otherwise experience if there is a long task ahead of it.

Regards,

John.................

Quote:

> I've read through quite a few books on ActiveX dlls and exes, the threading
> models, and everything that goes with it.  However I can't seem to find a
> book which will fully explain the topic in detail, thus I have a question.

> I have a standard exe project that I would like to be able to run multiple
> functions at once.  For instance, I have two buttons on a form and each
> button starts a search for a file in some dir.  I want the user to be able
> to push both of these buttons and the searches would happen concurrently.  I
> am thinking of having an activex dll which will do the searching and having
> that dll run apartment threading.  This should allow me to create an object
> of this dll for each search, each object on its own thread, doing its search
> on its own thread concurrently.

> However I don't think this is correct.  I can't seem to find any examples or
> articles on this topic exactly.  If somebody could enlighten me I would
> greatly appreciate it.

> james



Thu, 20 Nov 2003 04:42:08 GMT  
 threading question
Thanks John for the info.

Yes I am aware that the job will not get done faster but I need that
functionality so that several different jobs can be done while not having to
wait on each other to finish.  I'm actually making a server of sorts that
will have to perform different functions based on what clients are asking
for and I can't have the server performing one task at a time.

So then at a basic level, lets say that each new client that connects to my
server wants to run a long task.  I can spawn an Active X EXE that will take
care of their task without making the next clients that connect to the
server wait on that first client, correct?  I'll check out that coffee
example and see what I can come up with.

James


Quote:
> Hi James,

> ActiveX DLLs run in the same thread as the calling application so you
cannot use
> these to process several tasks from the same application in a separate
threads.
> To do background processing in separate threads you should use an ActiveX
EXE.
> The "Coffee" project in MSDN shows you how this can be done, and any good
book
> on the subject (e.g. Dan Appleman's "Developing Com/ActiveX Components in
VB6")
> will also give you examples.

> You should be aware (and perhaps you already are) that, with a single
processor,
> carrying out tasks concurrently will not get the overall job done faster
than
> having them carried out one after the other.  The processor simply shares
time
> among the tasks and thus each will be slower than if carried out
separately.
> However, concurrent processing will reduce the delay that a short task
might
> otherwise experience if there is a long task ahead of it.

> Regards,

> John.................


> > I've read through quite a few books on ActiveX dlls and exes, the
threading
> > models, and everything that goes with it.  However I can't seem to find
a
> > book which will fully explain the topic in detail, thus I have a
question.

> > I have a standard exe project that I would like to be able to run
multiple
> > functions at once.  For instance, I have two buttons on a form and each
> > button starts a search for a file in some dir.  I want the user to be
able
> > to push both of these buttons and the searches would happen
concurrently.  I
> > am thinking of having an activex dll which will do the searching and
having
> > that dll run apartment threading.  This should allow me to create an
object
> > of this dll for each search, each object on its own thread, doing its
search
> > on its own thread concurrently.

> > However I don't think this is correct.  I can't seem to find any
examples or
> > articles on this topic exactly.  If somebody could enlighten me I would
> > greatly appreciate it.

> > james



Fri, 21 Nov 2003 00:18:45 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Threading question

2. VB Threading Question With Code

3. VBNET Threading Question

4. Thread question

5. Repost: Simple thread question - MS incomplete article??

6. Threading Questions

7. Threading question

8. Threading question - OnIdle

9. Threading Question

10. 2 Thread questions:

11. Threading question

12. Multi-threading question

 

 
Powered by phpBB® Forum Software