Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to Halt The Next Procedure Until Previous is Finishe
Message
De
09/02/2014 09:53:42
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivie
 
 
À
09/02/2014 04:46:30
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows 8
Network:
Windows XP
Database:
Visual FoxPro
Application:
Desktop
Divers
Thread ID:
01593771
Message ID:
01593776
Vues:
42
So, if I understand correctly, for example a procedure "A" needs to wait for procedure "B" to finish. I would guess that procedure "B" would need to set up some sort of "mark" (for example, creating/deleting a file on disk), and procedure "A" regularly checks whether this "mark". To avoid consuming too much processing power in a tight loop, you can use something like WAIT with a timeout (still in a loop, though).

>Using Scan Endscan Loop I am converting a File Type "A" to File Type B and than File Type B to File Type C. There are around 80000 Files.
>
>The Process runs fine in General on a I7 Machine. Further, I implemented Parallel Fox in my code I got super efficiency and the Process of conversion of Type A to B was completed in just 1/3rd time of the previous time.
>
>The CPU showed 70-90 % Performance in conversion, BUT the System is not able to Write TYPE B File on Harddisk with enogh speed. Due to this reason Error occoured when Procedure for Type B to Type C runs. The Type B file is still not created and Procedure seeks file B for conversion to C.
>
>Means that The Process for conversion from B to C runs, but since the file type B is Not available ,the error occoured.
>
>What is to be done in such cases.
>
>How to Halt the Second procedure Until the entire Job of first Process is completed.
>
>Here is My Sample Code.
>
>
>
>nRECCOUNTCONVERT=ALLTRIM(STR(RECCOUNT()))
>cRECCOUNTCONVERT=' of '+ALLTRIM(STR(RECCOUNT()))
>Local loMyObject
>loMyObject = CreateObject("MyObject")
>_Screen.AddObject("oMyHandler", "MyHandler")
>loMyObject.Mainprocess()
>Return
>
>Define Class MyHandler as Custom
>Procedure DisplayProgress
>Lparameters lnPercent, lcMessage
>_VFP.StatusBar =  " ("  + "%)"
>EndProc 
>EndDefine 
>
>DEFINE CLASS MyObject AS Custom
>PROCEDURE Mainprocess
>Local Parallel as Parallel
>Parallel = NewObject("Parallel", "ParallelFox.vcx")
>Parallel.SetWorkerCount(Parallel.CPUCount)
>Parallel.StartWorkers()
>*Parallel.BindEvent("UpdateProgress", _Screen.oMyHandler, "DisplayProgress")
>
>SCAN
>iFilename=ALLTRIM(Fullpath)
>oFilename=ALLTRIM(Newpath)
>RCNON=RCNO
>*Parallel.do("PS2PDF",'convert.prg',,iFilename,oFilename)
>Parallel.CallMethod("ps2pdf", This.Class, This.ClassLibrary,,,iFilename,oFilename,RCNON)
>ENDSCAN
>
>SCAN
>oFilename=ALLTRIM(Fullpath)
>iFilename=ALLTRIM(Newpath)
>RCNON=RCNO
>Parallel.CallMethod("Pdf2Ps", This.Class, This.ClassLibrary,,,oFilename,iFilename,RCNON)
>ENDSCAN
>ENDPROC
>** Convert ps files to PDF Using ps2PDF.Dll
>PROCEDURE ps2PDF
>PARAMETERS iFilename,oFilename,RCNON
>DECLARE INTEGER _apCreate@0   IN ps2pdf.dll AS apCreate
>DECLARE         _apClose@4    IN ps2pdf.dll AS apClose   INTEGER id
>DECLARE INTEGER _apConvert@4  IN ps2pdf.dll AS apConvert INTEGER id
>DECLARE INTEGER _apSetFunc@24 IN ps2pdf.dll AS apSetFunc INTEGER id, INTEGER code, INTEGER nOptVal1, INTEGER nOptVal2, STRING pOptVal1, STRING pOptVal2
>DECLARE INTEGER _apGetFunc@24 IN ps2pdf.dll AS apGetFunc INTEGER id, INTEGER code, INTEGER nOptVal1, INTEGER nOptVal2, STRING pOptVal1, STRING pOptVal2
>#define AP_Set_Output     3000
>#define AP_Set_Input      3001
>id=apCreate()
>IF (id # 0)
>apSetFunc(id, AP_Set_Input , 0, 0,iFilename, 0)  &&input file.
>apSetFunc(id, AP_Set_Output, 0, 0,oFilename, 0) &&output format and file.
>apConvert(id)
>apClose(id)
>Sys(2335, 1)	&& disable unattended mode, allow UI
>WAIT WINDOW 'Converting to PDF..'+ALLTRIM(STR(RCNON)) NOWAIT
>*Worker.UpdateProgress(RECNO(), "Converting..")
>ENDIF
>ENDPROC
>
>PROCEDURE PDF2PS
>PARAMETERS oFilename,iFilename,RCNON
>Declare INTEGER VeryPDF_PDF2Vector in pdf2vec.dll String strCommandLine
>Strcmd= 'pdf2vec -$ XXXXXXXXXXXXXXXX '+CHR(34)+iFilename+CHR(34)+" "+CHR(34)+oFilename+CHR(34)
>nRet = VeryPDF_PDF2Vector(strcmd)
>Sys(2335, 1)	&& disable unattended mode, allow UI
>WAIT WINDOW 'Converting to PS..'+ALLTRIM(STR(RCNON)) NOWAIT
>RETURN
>ENDPROC
>ENDDEFINE
>Parallel.StopWorkers()
>
>
#define AP_Set_Input 3001
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform