[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.vb.general.discussion

Asynchronous and in-process?

Jason Keats

6/11/2012 4:20:00 AM

Is it possible, using only VB6 code, to perform tasks asynchronously -
without the use of ActiveX EXEs or third-party/closed-source DLLs?
12 Answers

Ralph

6/11/2012 4:53:00 AM

0

On Mon, 11 Jun 2012 14:20:04 +1000, Jason Keats
<jkeats@melbpcDeleteThis.org.au> wrote:

>Is it possible, using only VB6 code, to perform tasks asynchronously -
>without the use of ActiveX EXEs or third-party/closed-source DLLs?

Need more information, and probably a clearer definition of what you
mean by "asynchronous".

Shell and Wait, FindFirstChangeNotification, RegNotifyChangeKeyValue,
SendMessage, ... a whole slew of possibilities come to mind to manage
non-regular stop 'n start task processing.

Also, what does "third-party/closed-source DLLs" have to do with
anything?

-ralph

mm

6/11/2012 4:57:00 AM

0

"Jason Keats" <jkeats@melbpcDeleteThis.org.au> escribió en el mensaje
news:jr3rlj$fqr$2@speranza.aioe.org...
> Is it possible, using only VB6 code, to perform tasks asynchronously -
> without the use of ActiveX EXEs or third-party/closed-source DLLs?

What kind of tasks?
For example the WebBrowser control or the Internet Transfer control can
download files asynchronously... but I guess they could enter in the
category "closed-source DLLs".

You could shell another exe (not ActiveX) to do something asynchronously.

Perhaps what you are asking for is VB doing something like "multitasking",
but there is only one flow of execution, I mean, if you run a program in the
IDE step by step the yellow line is always one.

I know that with APIs you can start new threads, you can do some sort of
multithreading with some complex code, but I've never tried it (I never
needed it so far).


Ralph

6/11/2012 4:58:00 AM

0

On Mon, 11 Jun 2012 14:20:04 +1000, Jason Keats
<jkeats@melbpcDeleteThis.org.au> wrote:

>Is it possible, using only VB6 code, to perform tasks asynchronously -
>without the use of ActiveX EXEs or third-party/closed-source DLLs?

hmmm, I guess if you consider using the WinAPI as violating the "using
only VB6 code" requirement, then simple Event/s management should do
it.

-ralph

(Mike Mitchell)

6/11/2012 7:58:00 AM

0

On Mon, 11 Jun 2012 14:20:04 +1000, Jason Keats
<jkeats@melbpcDeleteThis.org.au> wrote:

>Is it possible, using only VB6 code, to perform tasks asynchronously -
>without the use of ActiveX EXEs or third-party/closed-source DLLs?

Yes. With Olaf Schmidt's add-on libraries it is. He wrote me a very
usable inclusion for my piano-tuition program. Before, I played back a
MIDI file and the virtual keyboard 'played' the corresponding keys.
But as soon as I moved the app form on the desktop, MIDI output froze,
until I stopped moving it.

With Olaf's inclusion, I can do anything I like with the main app and
MIDI output plus the virtual keyboard happily carry on working.

No doubt Olaf will respond to your post in due course. Meanwhile you
can look at his web site and especially the RichClient-Toolset and
DirectCOM:
http://www.thec...

MM

Jason Keats

6/11/2012 10:46:00 AM

0

ralph wrote:
> On Mon, 11 Jun 2012 14:20:04 +1000, Jason Keats
> <jkeats@melbpcDeleteThis.org.au> wrote:
>
>> Is it possible, using only VB6 code, to perform tasks asynchronously -
>> without the use of ActiveX EXEs or third-party/closed-source DLLs?
>
> Need more information, and probably a clearer definition of what you
> mean by "asynchronous".
>
> Shell and Wait, FindFirstChangeNotification, RegNotifyChangeKeyValue,
> SendMessage, ... a whole slew of possibilities come to mind to manage
> non-regular stop 'n start task processing.
>
> Also, what does "third-party/closed-source DLLs" have to do with
> anything?


Previously...

Farnsworth wrote:
> "Jason Keats" <jkeats@melbpcDeleteThis.org.au> wrote in message
> news:jr1eug$pvc$1@speranza.aioe.org...
>> Schmidt wrote:
>>> An async-reading needs perhaps only the addition
>>> of 3-5 lines to your already existing file-loop -
>>> and you can cut this time by half.
>>>
>>> If you're interested, I could post a class for that.
>>
>> Olaf, I (for one) am interested in how you have achieved (in-process)
>> asynchronous file loading. Please tell us more.
>
> Please post this question(perhaps rephrased) in a separate thread.
> Many newsgroup searchers would not find it otherwise.

As a result of the above this thread was begun.

If Olaf has a way, using a single class, of loading the contents of a
file into memory while our VB program remains free to do whatever, then
I'd like to hear more about it.

If it involves ActiveX EXEs, I'm not interested - most of us know how to
use such a thing without locking up our program's GUI. But that's a
non-blocking call to an out-of-process program.

If it involves using one of Olafs (closed-source) DLLs to run my code
(as a DLL) in-process in another thread, I'm not interested - as I like
to see the code.

I was hoping that the above weren't involved - that there was another way.

By the way, I'm happy with Wikipedia's definition of asynchronous:

In programming, asynchronous events are those occurring independently of
the main program flow. Asynchronous actions are actions executed in a
non-blocking scheme, allowing the main program flow to continue processing.

Jason Keats

6/11/2012 10:54:00 AM

0

MM wrote:
> On Mon, 11 Jun 2012 14:20:04 +1000, Jason Keats
> <jkeats@melbpcDeleteThis.org.au> wrote:
>
>> Is it possible, using only VB6 code, to perform tasks asynchronously -
>> without the use of ActiveX EXEs or third-party/closed-source DLLs?
>
> Yes. With Olaf Schmidt's add-on libraries it is.

Thanks MM. I was hoping that it didn't involve using Olaf's add-on
libraries (ie closed-source DLLs).


Schmidt

6/11/2012 1:25:00 PM

0

Am 11.06.2012 06:20, schrieb Jason Keats:
> Is it possible, using only VB6 code, to perform tasks asynchronously -
> without the use of ActiveX EXEs or third-party/closed-source DLLs?

The class I had in mind, is "selfcontained" and not
dependent on my libs.

Though it comes within the cairo-Tutorial-Download
(in Folder#: 14 Thumbnailing per ImageList).
www.datenhaus.de/Downloads/RC4cairoTutorial.zip

But to run the Demo (and the contained cAsyncFileRead.cls)
in a "useful context", you would have to install the
RC4-BaseLibs beforehand.

Or just take a look at the code within the Demo-Form
in the #14-Example, copy the class over into your own app -
and write your own FileLoop, based on what you find there...

Or just ask questions, in case you cannot get it to work.

The class is relatively simple - it is using overlapped IO
which is offered by the plain CreateFile/ReadFile Win32-API.

Though note, that apparently on Win7 (not sure about Vista)
the Overlapped (async)-behaviour is in the meantime only
"faked" - tried yesterday, to change the class to different
schemes (also based on the WIn32-API), but to no success.
Win7 stubbornly does not do anything asyncronous on the
File-Subsystem.

- the original Class is based on ReadFile and FILE_FLAG_OVERLAPPED
- tried ReadFileEx in combination with IOCompletion-Callbacks
- also tried IOCompletionPorts

All to no avail on WIn7 - I mean, the APIs deliver exactly
what one expects (e.g. ReadFile returns ERROR_IO_PENDING
also on Win7 - and later on the GetOverlappedResult-API
works the same as on XP ... it's just that on Win7 already
the *triggering* of the stuff per ReadFile does all the
complete FileReading under the hood - instead of (as on XP) -
doing nothing for the moment (aside from "noting" the Request)
and return ERROR_IO_PENDING.

So although Win7 returns the same async-error-notifications -
so that the usage of the async APIs is not broken -
its behaviour is not the same as on XP because it completes
the JOB already in the "initialization-call" - and then
hands out just "faked notification-results".

SO I tried to enhance the class yesterday, but neither
thing (IOCallbacks or IOCOmpletionPorts) worked - I mean
they "worked" - but asynchronously only on XP.

So it seems that for real async FileOps on Win7, one will
have to use threads finally.


-----------------------------------------------------
BTW, what's useful for testing such stuff is something
to clear the current System-Filecache (without rebooting):

'to be run within an App, which was started with Admin-rights
Public Sub CleanupFileCacheOnDrive(DriveChar As String)
Dim hFile As Long
hFile = CreateFile("\\.\" & Left$(DriveChar, 1) & ":", _
FILE_READ_ACCESS Or SYNCHRONIZE, _
FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0)

If hFile <> INVALID_HANDLE_VALUE Then CloseHandle hFile
End Sub


Here the Const- and Declare-stuff for the above:

Private Const INVALID_HANDLE_VALUE& = -1, OPEN_EXISTING& = 3
Private Const FILE_READ_ACCESS& = 1, SYNCHRONIZE& = &H100000
Private Const FILE_SHARE_READ& = 1, FILE_SHARE_Write& = 2


Private Declare Function CreateFile& Lib "kernel32" Alias "CreateFileA"
(ByVal lpFileName$, ByVal dwDesiredAccess&, ByVal dwShareMode&, ByVal
lpSecurityAttributes&, ByVal dwCreationDisposition&, ByVal
dwFlagsAndAttributes&, ByVal hTemplateFile&)
Private Declare Function CloseHandle& Lib "kernel32" (ByVal hObject&)

Olaf

Martin KoWi

6/11/2012 2:49:00 PM

0

Am 11.06.2012 15:25, schrieb Schmidt:

> Win7 stubbornly does not do anything asyncronous on the
> File-Subsystem.

Hi Olaf,

There was a discussion about this topic:

http://social.msdn.microsoft.com/Forums/en-US/windowsgeneraldevelopmentissues/thread/8941dc4b-8c91-406b-884b-36...

the last post on this page might explain this behaviour.
see also the link to the KB-article.

martin.

(Mike Mitchell)

6/11/2012 3:55:00 PM

0

On Mon, 11 Jun 2012 20:54:25 +1000, Jason Keats
<jkeats@melbpcDeleteThis.org.au> wrote:

>MM wrote:
>> On Mon, 11 Jun 2012 14:20:04 +1000, Jason Keats
>> <jkeats@melbpcDeleteThis.org.au> wrote:
>>
>>> Is it possible, using only VB6 code, to perform tasks asynchronously -
>>> without the use of ActiveX EXEs or third-party/closed-source DLLs?
>>
>> Yes. With Olaf Schmidt's add-on libraries it is.
>
>Thanks MM. I was hoping that it didn't involve using Olaf's add-on
>libraries (ie closed-source DLLs).

But surely you use ActiveX controls without having access to the
source code?

MM

Jason Keats

6/12/2012 3:47:00 PM

0

Schmidt wrote:
> Am 11.06.2012 06:20, schrieb Jason Keats:
>> Is it possible, using only VB6 code, to perform tasks asynchronously -
>> without the use of ActiveX EXEs or third-party/closed-source DLLs?
>
> The class I had in mind, is "selfcontained" and not
> dependent on my libs.
>
> Though it comes within the cairo-Tutorial-Download
> (in Folder#: 14 Thumbnailing per ImageList).
> www.datenhaus.de/Downloads/RC4cairoTutorial.zip
>
> But to run the Demo (and the contained cAsyncFileRead.cls)
> in a "useful context", you would have to install the
> RC4-BaseLibs beforehand.
>
> Or just take a look at the code within the Demo-Form
> in the #14-Example, copy the class over into your own app -
> and write your own FileLoop, based on what you find there...
>
> Or just ask questions, in case you cannot get it to work.
>
> The class is relatively simple - it is using overlapped IO
> which is offered by the plain CreateFile/ReadFile Win32-API.
>
<snipped>

Thanks, Olaf, for the detailed reply. I'm sure I'll eventually get your
code running - probably when I can find the correct Cairo DLLs.

I don't recall every using any Windows DLLs in an asynchronous fashion -
so it will be interesting to study your code to see how that works. I'm
just sorry I didn't get the time today.