Microsoft KB Archive/190885

= PRB: Cannot Cancel AsyncRead When Used With Local Files =

Article ID: 190885

Article Last Modified on 12/10/2003

-

APPLIES TO


 * Microsoft Internet Explorer 4.0 128-Bit Edition
 * Microsoft Internet Explorer 4.01 Service Pack 2
 * Microsoft Visual Basic 6.0 Learning Edition
 * Microsoft Visual Basic 6.0 Professional Edition
 * Microsoft Visual Basic 6.0 Enterprise Edition

-



This article was previously published under Q190885



SYMPTOMS
When using AsyncRead from a ActiveX Document or an ActiveX Control project running under Internet Explorer 4.x to download a local file, you cancel the operation by calling CancelAsyncRead. CancelAsyncRead does not work for local files.



CAUSE
Reading a local file is a Synchronous operation. For this reason the call to AsyncRead is completed before any subsequent lines of code are executed.



Steps to Reproduce Behavior
 Create a blank ActiveX Document project in Visual Basic 6.0.  Insert the following code in the project: Private Sub UserDocument_AsyncReadComplete(AsyncProp as  AsyncProperty) MsgBox "CancelAsyncRead didn't work. Downloaded " & _ AsyncProp.BytesRead & " Bytes" End Sub

Private Sub UserDocument_Show 'use a large file here AsyncRead "c:\windows\system\mshtml.dll", vbAsyncTypeByteArray MsgBox "Notice that CancelAsyncRead hasn't been called yet!" CancelAsyncRead End Sub  Run your project and load the Visual Basic Document in Internet Explorer 4.x

You will see the MsgBox in AsyncReadComplete is shown before the MsgBox in UserDocument_Show. This means that the AsyncReadComplete event is fired before CancelAsyncRead could be called.

Keywords: kbactivedocs kbprb KB190885

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.