Re: Semi-multithreaded application in VB6




"Matthias Julius" <jnews@xxxxxxxxxxxxxx> wrote in message
news:uslsszz0c.fsf@xxxxxxxxxxxxxxxxx
> "Steve Gerrard" <mynamehere@xxxxxxxxxxx> writes:
>
>> Question for you: where are you doing your DoEvents? The user won't be able
>> to
>> intervene except where you yield enough to let a button click get through.
>> That
>> would seem to be the place for your flag check as well.
>
> There are a number of wait times in the cycle. You are raising a good
> point here. If there is only a chance of a click event to get through
> during those wait times it doesn't make sense to check this flag.
>
> But, there is also a sub called by a timer periodically that might set
> it. I presume your point is true for timer events as well.
>

Yup, the timer control event won't fire until you call DoEvents or the current
executing process finishes.

> And there are calls to dll functions that take some time to complete.
> I don't know whether they block processing of events or not.
>
Generally yes.

I have a program that does some long distance file copying over the network at
work. It copies files in blocks, with a DoEvents after each block to update
progress and allow cancelling. For some locations, this can mean 10 seconds may
go by before the copying actually gets cancelled. For this kind of operation,
though, I think that is reasonable.

I would go with a main loop that did one large step of the process in each
cycle, followed by one DoEvents and flag check. Make the steps big enough that
you are checking only every 3 seconds or so; that would give a reasonable cancel
response, without bogging your code down with endless checking.



.



Relevant Pages

  • Re: Semi-multithreaded application in VB6
    ... where are you doing your DoEvents? ... > intervene except where you yield enough to let a button click get through. ... during those wait times it doesn't make sense to check this flag. ...
    (comp.lang.basic.visual.misc)
  • Re: How to escape out of a loop
    ... doevents in VisualBasic or VBA will not stop a loop at any ... We get the same functionality by the settimer called subs. ... can then change the Boolean flag variable. ...
    (microsoft.public.scripting.vbscript)
  • Re: How to escape out of a loop
    ... doevents in VisualBasic or VBA will not stop a loop at any ... We get the same functionality by the settimer called subs. ... can then change the Boolean flag variable. ...
    (microsoft.public.scripting.vbscript)
  • Re: DoEvents Alternatives
    ... the workaround doesn't solve it. ... DoEvents makes the program execution loops in the mouse_move event and outs ... a last resort set a flag variable, call doevents and clear the flag and ...
    (microsoft.public.vb.winapi)
  • Re: Event Handling in vb.net
    ... it appears to block the Timer event. ... If you are super paranoid about it, I would suggest you protect all events. ... Me I only protect those routines that I know I am calling DoEvents ... Handlers may call MessageBox.Show to display exceptions to the user, ...
    (microsoft.public.dotnet.languages.vb)