'DoEvents' inside ActiveX DLL 
Author Message
 'DoEvents' inside ActiveX DLL

In objects inside my ActiveX DLL, there are some methods which send a
query to the database, then process the results a little, and then
return. Would it help peformance to place a 'DoEvents' after fetching
results from the database and before processing the results? I have
been recently trying to figure out threading with VB and COM, and have
seen the injunction for avoiding 'DoEvents' in DLL's, but it is still
not clear to me and I need a confirmation. TIA.


Sun, 03 Oct 2004 05:26:58 GMT  
 'DoEvents' inside ActiveX DLL


Fri, 19 Jun 1992 00:00:00 GMT  
 'DoEvents' inside ActiveX DLL
When you say performance, what do you mean? Speed or client interface screen
updates (so the mouse is still usable).
 The former, no, the latter yes.

If you go for Doevents (peekMessage) then be circumspect, don't splatter
them all over the place, in a big loop you really want to do something like
this:
For i& = 0 to nLoop-1
    ..... 'Do whatever thoust wilt
    If  i& Mod 1000 = 0 Then DoEvents
Next i&

or explicitly call a screen update if you can e.g. frmMain.refresh
or explicitly flash the cursor Screen.mousepointer =
vbDefault:screen.mouspointer = vbhourglass to give the user comfort
feedback. Use the Mod operator to do this every so many iterations or insert
the Doevents/Update statement within an outer loop if the inner loop is big,
you could then update an outer loop counter

As for within a dll, I've found on a local machine, there shouldn't be
problems unless you put Doevents in a stupid place! In some COM components
being called you absolutely have to use it in the calling loop (to yield
THEIR message loop).

Anybody else for better advice re: Doevents in dll's - I'm open to
correction here!


Quote:
> In objects inside my ActiveX DLL, there are some methods which send a
> query to the database, then process the results a little, and then
> return. Would it help peformance to place a 'DoEvents' after fetching
> results from the database and before processing the results? I have
> been recently trying to figure out threading with VB and COM, and have
> seen the injunction for avoiding 'DoEvents' in DLL's, but it is still
> not clear to me and I need a confirmation. TIA.



Sun, 03 Oct 2004 19:57:21 GMT  
 'DoEvents' inside ActiveX DLL
Thanks for your response.

What I was concerned about was reentrancy. This component
will be running on the server and activated by web
clients. I was reasoning that since multiple requests
would be received to use the DLL, placing a DoEvents just
after getting results from the database could free the
processor to service another request, thereby aiding
performance to some degree. My question was is reentrancy
an issue? I was trying to understand the articles at
http://search.microsoft.com/gomsuri.asp?
n=1&c=rp_Results&siteid=us/dev&target=http://msdn.microsoft
.com/library/en-
us/vbcon98/html/vbconapartmentmodelmultithreadinginvisualba
sic.asp and http://search.microsoft.com/gomsuri.asp?
n=2&c=rp_Results&siteid=us/dev&target=http://msdn.microsoft
.com/library/en-
us/vbcon98/html/vbcondesigningthreadsafedlls.asp. I am
using the default model: apartment-threaded. My guess was
placing the 'DoEvents' was not going to be harmful. I need
a confirmation.

TIA.

Quote:
>-----Original Message-----
>When you say performance, what do you mean? Speed or

client interface screen
Quote:
>updates (so the mouse is still usable).
> The former, no, the latter yes.

>If you go for Doevents (peekMessage) then be circumspect,
don't splatter
>them all over the place, in a big loop you really want to
do something like
>this:
>For i& = 0 to nLoop-1
>    ..... 'Do whatever thoust wilt
>    If  i& Mod 1000 = 0 Then DoEvents
>Next i&

>or explicitly call a screen update if you can e.g.
frmMain.refresh
>or explicitly flash the cursor Screen.mousepointer =
>vbDefault:screen.mouspointer = vbhourglass to give the
user comfort
>feedback. Use the Mod operator to do this every so many

iterations or insert

- Show quoted text -

Quote:
>the Doevents/Update statement within an outer loop if the
inner loop is big,
>you could then update an outer loop counter

>As for within a dll, I've found on a local machine, there
shouldn't be
>problems unless you put Doevents in a stupid place! In
some COM components
>being called you absolutely have to use it in the calling
loop (to yield
>THEIR message loop).

>Anybody else for better advice re: Doevents in dll's -
I'm open to
>correction here!


message

>> In objects inside my ActiveX DLL, there are some

methods which send a

- Show quoted text -

Quote:
>> query to the database, then process the results a
little, and then
>> return. Would it help peformance to place a 'DoEvents'
after fetching
>> results from the database and before processing the
results? I have
>> been recently trying to figure out threading with VB
and COM, and have
>> seen the injunction for avoiding 'DoEvents' in DLL's,
but it is still
>> not clear to me and I need a confirmation. TIA.

>.



Sun, 03 Oct 2004 21:20:30 GMT  
 'DoEvents' inside ActiveX DLL
Despite all I have read, in practice I've not (maybe once or twice in 10
years) had what I unserstood to be re-entrancy problems.

I think as I said that if you are reasonably circumspect about how many and
where you put them, they are a real boon, to general feel and responsiveness
of an app. So maybe we should just suck it and see and maybe also seek
really good advice elswhere -
Dan Appleman's books and one I rate highly, Advanced Microsoft Visual Basic
6.0 2nd Edition by 'The Mandelbrot Set' (International) Ltd (run by a guy
called 'Peet' Morris - its a Microsoft Press book and can be got at agood
price from VBUG, the UK's Visual Basic User Group - its by a consortium of
programmers from TMS and is real live fantastic in depth analyses of
evrything to do with programming in VB. TMS have  great reputation at
Microsoft I believe, and this book shows why. they design programs from the
ground up and the in-house systems to get them built without bugs.

Happ hunting,

Clive


Quote:
> Thanks for your response.

> What I was concerned about was reentrancy. This component
> will be running on the server and activated by web
> clients. I was reasoning that since multiple requests
> would be received to use the DLL, placing a DoEvents just
> after getting results from the database could free the
> processor to service another request, thereby aiding
> performance to some degree. My question was is reentrancy
> an issue? I was trying to understand the articles at
> http://search.microsoft.com/gomsuri.asp?
> n=1&c=rp_Results&siteid=us/dev&target=http://msdn.microsoft
> .com/library/en-
> us/vbcon98/html/vbconapartmentmodelmultithreadinginvisualba
> sic.asp and http://search.microsoft.com/gomsuri.asp?
> n=2&c=rp_Results&siteid=us/dev&target=http://msdn.microsoft
> .com/library/en-
> us/vbcon98/html/vbcondesigningthreadsafedlls.asp. I am
> using the default model: apartment-threaded. My guess was
> placing the 'DoEvents' was not going to be harmful. I need
> a confirmation.

> TIA.

> >-----Original Message-----
> >When you say performance, what do you mean? Speed or
> client interface screen
> >updates (so the mouse is still usable).
> > The former, no, the latter yes.

> >If you go for Doevents (peekMessage) then be circumspect,
> don't splatter
> >them all over the place, in a big loop you really want to
> do something like
> >this:
> >For i& = 0 to nLoop-1
> >    ..... 'Do whatever thoust wilt
> >    If  i& Mod 1000 = 0 Then DoEvents
> >Next i&

> >or explicitly call a screen update if you can e.g.
> frmMain.refresh
> >or explicitly flash the cursor Screen.mousepointer =
> >vbDefault:screen.mouspointer = vbhourglass to give the
> user comfort
> >feedback. Use the Mod operator to do this every so many
> iterations or insert
> >the Doevents/Update statement within an outer loop if the
> inner loop is big,
> >you could then update an outer loop counter

> >As for within a dll, I've found on a local machine, there
> shouldn't be
> >problems unless you put Doevents in a stupid place! In
> some COM components
> >being called you absolutely have to use it in the calling
> loop (to yield
> >THEIR message loop).

> >Anybody else for better advice re: Doevents in dll's -
> I'm open to
> >correction here!


> message

> >> In objects inside my ActiveX DLL, there are some
> methods which send a
> >> query to the database, then process the results a
> little, and then
> >> return. Would it help peformance to place a 'DoEvents'
> after fetching
> >> results from the database and before processing the
> results? I have
> >> been recently trying to figure out threading with VB
> and COM, and have
> >> seen the injunction for avoiding 'DoEvents' in DLL's,
> but it is still
> >> not clear to me and I need a confirmation. TIA.

> >.



Mon, 04 Oct 2004 01:18:36 GMT  
 'DoEvents' inside ActiveX DLL
Hi!

As I understood, you mixed client requests with VB events. If you look into
your asp code, you will see that there is created new instance of your
object (createObject("library.class")) for each request from client and they
all run independantly. There can be many of the same object running at the
same time but you (objects) can't feel it because they all run in their own
process. I think there is notrhing wrong using Smith's syntax, but I assume
that you don't need it any more.

Are you using COM+, 'coz there's a lot of interesting artricles about it.

- Jure



Mon, 04 Oct 2004 16:01:03 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. What's the differance between a ActiveX.dll and regular dll's

2. ActiveX dll's and EXE's

3. Licensing for ActiveX DLL's and EXE's

4. Using the MDI Child property on GUI's gen'd by an ActiveX DLL

5. ActiveX dll's and EXE's

6. Finding functions inside DLL's?

7. ActiveX DLL events won't fire when DLL shows Modal Form

8. _,.+*'^'*+.,_ ACTiVEX OCX TRADE _,.+*'^'*+.,_

9. Listing Dir's inside Dir's

10. character '^' inside a sql query

11. the '#' character inside a string

12. Accessing IE5 DOM from inside my clientside activex obj in a activex dll

 

 
Powered by phpBB® Forum Software