Archived Forum Post

Index of archived forum posts

Question:

Events and abortCheck with ActiveX components

Jan 30 '14 at 11:56

Hello, How can I use the AbortCheck / events capabilitiers for the ActiveX components. The zip2 and mailman reference documentations (http://www.chilkatsoft.com/refdoc/xChilkatZip2Ref.html ...) describe a HeartBeat properties but no event is described and the AbortCheck callback is not documented. Is there any possibility to monitor the completion (percentage done) of a task for ActiveX components ?

Thank you!


Accepted Answer

For WriteZipPercentDone (which will change to "PercentDone" in the next version (v9.5.0) of Chilkat).

WriteZipPercentDone(ByVal pctDone As Long, abort As Long)

(This description is for the standardized "PercentDone" event in the next version, but applies to WriteZipPercentDone) Provides the percentage completed for any method that involves network communications or time-consuming processing. This event is only fired when it is possible to know a percentage completion, and when it makes sense to express the operation as a percentage completed. The pctDone argument will have a value from 1 to 100. For operations (Chilkat method calls) that complete very quickly, the number of PercentDone callbacks will vary, but the final callback should have a value of 100. For long running operations, no more than one callback per percentage point will occur (for example: 1, 2, 3, ... 98, 99, 100). The abort output argument provides a means for aborting the operation. Setting it to 1 will cause the method to abort and return a failed status (or whatever return value indicates failure).

The PercentDone callback counts as an AbortCheck event. For method calls that complete quickly such that PercentDone events fire, it may be that AbortCheck events don't fire because the opportunity to abort is already provided in the PercentDone callback. For time consuming operations, where the amount of time between PercentDone callbacks are long, AbortCheck callbacks may be used to allow for the operation to be aborted in a more responsive manner.

VB6 Event callback implementation:

Dim WithEvents myZip As ChilkatZip

Private Sub myZip_WriteZipPercentDone(ByVal pctDone As Long, abort As Long)

'Insert application code here.

End Function


Answer

If using VB6, this is how you would use the AbortCheck event:

AbortCheck(abort As Long)

Provides the opportunity for a method call to be aborted. The AbortCheck event is fired periodically based on the value of the HeartbeatMs property. If HeartbeatMs is 0, then no AbortCheck events will fire. As an example, to fire 5 AbortCheck events per second, set the HeartbeatMs property equal to 200.

VB6 Event callback implementation:

Dim WithEvents myZip As ChilkatZip

Private Sub myZip_AbortCheck(abort As Long)

'Insert application code here.

End Function


Answer

The UnzipPercentDone event is the same as WriteZipPercentDone, with only a difference in the name. In v9.5.0, these events coalesce into a single PercentDone event. This will be documented in the release notes, and an alternative backward-compatible DLL will be provided in v9.5.0 as well (but apps will need to switch to the new API w/ the new DLL to move beyond v9.5.0) see http://www.chilkatforum.com/questions/4692/next-activex-update