Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to Halt The Next Procedure Until Previous is Finished
Message
De
09/02/2014 04:46:30
 
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
How to Halt The Next Procedure Until Previous is Finished
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:
01593771
Vues:
47
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()
Harsh
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform