Re: VB6 (formless) Timer class
- From: "2b|!2b==?" <user@xxxxxxxxxxxxxx>
- Date: Sun, 20 Jan 2008 13:51:56 +0000
Larry Serflaten wrote:
There is no need to re-invent the wheel. VB ships with a Timer control
for use on its forms. You can use a form and timer without having to
show the form to the user. Doing so will let you use familiar code to
handle your task.
The problem with this is that the "Event classes" become unnecessarily heavy (containing a form that has to be created, consumes resources, and is not seen), plus I want to minimise the number of ActiveX controls I use in my project. So if there is a way I can obtain the same functionality without using an ActiveX control, I prefer it.
What you need to be concerned about is the thread used to execute
your tasks. If you sit and wait for incoming calls, things will go smoothly,
until you start responding to those calls. If you send a class off to do
some 'asyncronous' task, then part of your application's processing has
to include the time necessary to do that task. If that task is processor
intensive, then it wil effect your ability to respond to incoming calls.
After launching some number of those intensive tasks all trying to run at
the same time, you will find you are no better off than if you'd responded
to the calls directly. That is because your entire program can only execute
*one line of code at a time*.
If execution is taking place in a CPU hogging routine, (no DoEvents) then all
other processing in your application grinds to a halt until that routine has ended.
That includes the code you want responding to incoming calls.
Since you can only execute one line of code at a time, tasks (routines) that
have no DoEvents are going to run to completion, before any other task
you may have started. In essence you will have built a queue where the first
tasks in run to completion, ahead of any other task created.
If the 'queue' response is acceptable to you, why not build it as a queue,
(a bit simpler) instead of the not-so-asycnronous multiple tasks?
Yes, this sounds interesting, could you tell me more - could you clarify what you mean by "build it as a queue" ?
If the queue method is not acceptable, and you really want those tasks to
run asyncronously, then you need to give them their own thread, their own
process, in which to complete their task. Again, you need not re-invent the
wheel, VB's ActiveX exe projects run their own process and can be created
and controlled from your VB application.
So, in a nutshell, what is it you really want to do?
Actually threading etc are red herrings - my main objective is to be able to handle large numbers of data coming in via WM_COPYDATA messages - WITHOUT dropping one. I remember reading somewhere, that windows messages remain on the message queue - either until they are read off the queue by the application OR until they timeout (IIRC, the timeout is specified in the SendMessage function call - but I'm sure someone will correct me if I am wrong). However, I read a thread a little while ago, where someone had asked the question as to whether messages sent by WM_COPYDATA are guaranteed to be read of the queue by the application - and IIRC, someone replied to say that if the application is busy (for example, waiting for user import etc), then all bets are off, and the messages will just "fall off" .... this is what I'm trying to prevent .... if messages can "fall off", then I need to find a way of preventing that, thats what I'm trying to do in a nutshell.
.
LFS
- Follow-Ups:
- Re: VB6 (formless) Timer class
- From: Larry Serflaten
- Re: VB6 (formless) Timer class
- From: Mike Williams
- Re: VB6 (formless) Timer class
- References:
- VB6 (formless) Timer class
- From: 2b|!2b==?
- Re: VB6 (formless) Timer class
- From: Larry Serflaten
- VB6 (formless) Timer class
- Prev by Date: Re: VB6 SendMessage and WM_COPYDATA
- Next by Date: WindowMessages that activate a form
- Previous by thread: Re: VB6 (formless) Timer class
- Next by thread: Re: VB6 (formless) Timer class
- Index(es):
Relevant Pages
|
Loading