Author Topic: Chilkat ZIP - Async methods cause crash on release in VFP9  (Read 820 times)

rcahoon

  • Newbie
  • *
  • Posts: 2
  • Karma: +0/-0
    • View Profile
Chilkat ZIP - Async methods cause crash on release in VFP9
« on: December 26, 2017, 03:24:05 PM »
Hi,

I am trying to use the Chilkat ZIP ActiveX dll in our VFP9 system and I'm having problems making the Async methods work.

Basically, everything works perfectly until I release my task object which results in VFP9 crashing. This doesn't occur using the non-async methods.

Anyone have any pointers as to what might be wrong??

Code: [Select]
LOCAL lotask, lozip, lnsuccess, lnrecurse, lcfolder

lcappendfrom = "D:\DATA\SHF"
lcfilespec = "APPS\*"
lnrecurse = 1

lozip = CREATEOBJECT('Chilkat_9_5_0.Zip')
lozip.unlockcomponent("unlock")

lnsuccess = lozip.newzip("_myZip.zip")

lozip.appendfromdir = lcappendfrom
lnsuccess = lozip.appendfiles(lcfilespec,lnrecurse)

lotask = lozip.writezipandcloseasync()

lnsuccess = lotask.RUN()
IF (lnsuccess <> 1) THEN
? lotask.lasterrortext
CANCEL
ENDIF

lncurpctdone = 0
DO WHILE lotask.finished <> 1

IF (lotask.percentdone <> lncurpctdone) THEN
lncurpctdone = lotask.percentdone
WAIT WINDOW STR(lncurpctdone) + " %" NOWAIT
ENDIF

*  Sleep 100 ms.
loTask.SleepMs(100)
ENDDO

MESSAGEBOX( "WriteZipandClose Complete: " + ALLTRIM(STR(lnsuccess)))

MESSAGEBOX( lotask.StatusInt)
MESSAGEBOX( lotask.getresultint())

RELEASE lotask            && THIS COMMAND CRASHES VFP9

RETURN

Cheers,

Rob

TracyP

  • Newbie
  • *
  • Posts: 8
  • Karma: +0/-0
    • View Profile
Re: Chilkat ZIP - Async methods cause crash on release in VFP9
« Reply #1 on: January 05, 2018, 05:05:30 PM »
VFP has trouble with threaded objects. I never got the ASYNC methods to work reliably.

We use EVENTHANDLER() to connect the Chilkat object to a VFP object that Implements the interface _IChilkatZipEvents to update the UI. We only use the _IChilkatZipEvents_PercentDone procedure in the class.

rcahoon

  • Newbie
  • *
  • Posts: 2
  • Karma: +0/-0
    • View Profile
Re: Chilkat ZIP - Async methods cause crash on release in VFP9
« Reply #2 on: January 05, 2018, 06:31:38 PM »
Tracy,

Matt from Chilkat provided me with the solution. Turns out you need to run Global.FinaliseThreadPool prior to releasing your task and global objects in VFP. Once I added this call to my shutdown routine the asynch events started working just fine. That said, I've only done fairly straight forward testing so far.

As I see it, both linked events and asynch callbacks provide you with the basic ability to track and/or abort the current process though I would like to use asynch methods for the improved performance offered due to the ability to take advantage of multiple, pooled threads.

Did your solution use the Finalise Thread pool command and still have issues in VFP?

Cheers,

Rob

TracyP

  • Newbie
  • *
  • Posts: 8
  • Karma: +0/-0
    • View Profile
Re: Chilkat ZIP - Async methods cause crash on release in VFP9
« Reply #3 on: January 05, 2018, 06:47:47 PM »
My testing did not have that. It may have been added after I decided to just use the EventHandler(). Or I never saw it.
I'll keep that in mind for the future.
Currently I don't have a need to use the threads that way, but might before I'm finished with VFP.

Thank you,
Tracy