From: xytsrm on
Thanks Guys,

The bottom line seems to be it's not very easy to overcome the Ad Hoc use of
"DoEvents" in VB6. Which I am currently doing, and although it works fine, I
just don't like the structure.

May have to embrace vb.Net....eventually.


"Dee Earley" wrote:

> On 04/08/2010 17:38, xytsrm wrote:
> > Hi Tom,
> >
> > This is not specifically about the MCI control, it's just that the control
> > illistrates how VB events get suspended; in this case they are suspended
> > during the synchronous "Play", forcing the use of asynchronous mode, looping
> > until "Stop" and including "DoEvents" in the loop. I also use other
> > functions that suspend the event processing, leading to a very Ad Hoc
> > collection of loops containing "DoEvents". I was hoping I could find a
> > system function (e.g. timer) that could call a single function in my app on
> > at a regular interval and not be suspended by any other process. That
> > function would contain the "DoEvents", insuring all events were processed
> > regardless of whether a given control was being used synchronously. It would
> > seem that this should be possible, given that the OS does continue processing
> > events, regardless of indivudual apps. I am surprised that VB doesn't
> > provide some capability to multi-task event processing without the need for
> > the scattering of "DoEvents" around code. Your comments on the way callbacks
> > work re-enforces my opinion that "Dan Appleman's" server approach won't work
> > either. Do you know whether this issue has been overcome in VB Net?
> It essentially comes down to threading.
> A thread can only do one single thing at a time.
> Sadly VB6 natively only really supports a single thread (*).
> If your code calls other code (that is synchronous) then it will be
> blocked until it returns.
> This "block" also includes processing of windows messages, redrawing, etc.
> If the code calls DoEvents then it allows these to be processed before
> it has returned control to your code.
> Asynchronous normally means it moves everything off to a background
> thread and allows your code to carry on as before, but there are some
> exceptions that will just call Doevents allowing other code to run, but
> STILL blocking your thread of execution (it hasn't returned).
> * Multithreading in VB6 is possible but very awkward to handle.
> You either use out of process COM objects (ActiveX EXEs) or some very
> carefully written API code to handle TLS (or lack of) but you can't
> easily call other objects.
> ..NET (cue flames..) allows you do do background tasks a lot easier so
> you can start off one video on a background thread while your UI threads
> carries on processing messages and idling.
> Reading that back, it makes some sense so I'll send it anyway... :)
> --
> Dee Earley (dee.earley(a)
> i-Catcher Development Team
> iCode Systems
> (Replies direct to my email address will be ignored.
> Please reply to the group.)
> .