Share via


Visual Basic Reference

AsyncReadProgress Event

See Also    Example    Applies To

Occurs when more data is available as a result of an AsyncRead method.

Syntax

Subobject_AsyncReadProgress(AsyncPropAs AsyncProperty)

The AsyncReadProgress event syntax has these parts:

Part Description
Object An object expression that evaluates to an object in the Applies To list.
AsyncProp An AsyncProperty object.

Remarks

The AsyncReadProgress event gives you access to the progressive status of an asynchronous download.

If the AsyncType for the AsyncRead method is set to either vbAsyncTypeFileName or vbAsyncTypeByteArray, you can have access to the partially downloaded data during a download. Normally, Visual Basic keeps the file open during the entire download process. Getting the Value for vbAsyncTypeFileName slows the download process (but not significantly over a slow link), because Visual Basic must close the file each time before firing the event, and then re-open the file the next time data is available.

If you open the file, then you must close it before the code inside the AsyncReadProgress event completes (or before calling DoEvents or otherwise allowing a Windows message to be dispatched), otherwise an error will occur, preventing the AsyncReadProgress event from firing. To avoid this, include error-handling code in the AsyncReadComplete event procedure.

Note   The firing of the AsyncReadProgress and AsyncReadComplete events is message-based. That is, a Windows notification message is posted and must be dispatched by the applications message pump to fire. Therefore, you should avoid loop structures in the code of these events. Also avoid using DoEvents, since it'll unexpectedly cause the code to be re-entrant.

Both the AsyncReadProgress and AsyncReadComplete events occur when the download completes. (That is, AsyncProp.StatusCode = vbAsyncStatusCodeEndDownloadData.)