Parallrlfox - how to run a form method

Jul 19, 2013 at 5:55 PM
How to run a form method using parallelfox ?

Now I am running method like :

thisform.addless()

How to run above method using parallelfox ?


Warm regards,
mk.
Jul 19, 2013 at 6:12 PM
Is below code work ?

parallel = NewObject("parallel","parallelfox.vcx")
parallel.callmethod("addless",this)


Warm regards,
mk.
Developer
Jul 19, 2013 at 7:45 PM
mk,

No, that will not work. CallMethod() expects the name of a class and VCX, so it can instantiate the class before running the method. What you could do is move the code from the Addless() method to a PRG or separate class, then you could run it in ParallelFox. Note that if the existing code references controls or properties on the form, it won't work, because ParallelFox can't see the form. Consider each worker a separate instance of FoxPro.

Hope this helps,

Joel
Jul 20, 2013 at 5:56 AM
Thank you,

I have below code in thisform.addless method :

 SELECT inward1
 FLUSH IN inward1
 LOCAL lxreco1
 LOCAL nnsal3tqty, nnsal3tamt, nnsal3tplusminamt, nnsal3tscheme, nnsal3ttdamt, nnsal3tcdamt, nnsal3texcise, nnsal3ttaxamt, nnsal3tvatamt, nnsal3toctroi, nnsal3tfreight, nnsal3tcnamt, nnsal3gadd, nnsal3gless, nnsal3gtbamt
 lxreco1 = inward.reco1
 salrec = RECNO()
 SELECT qty, amt, plusminamt, scheme, tdamt, cdamt, excise, taxamt, vatamt, octroi, freight, cnamt, add, less, tbamt FROM inward1 WITH (BUFFERING=.T.) WHERE reco1=lxreco1 INTO CURSOR tempinward1
 SELECT tempinward1
 SUM qty, amt, plusminamt, scheme, tdamt, cdamt, excise, taxamt, vatamt, octroi, freight, cnamt, add, less, tbamt TO nnsal3tqty, nnsal3tamt, nnsal3tplusminamt, nnsal3tscheme, nnsal3ttdamt, nnsal3tcdamt, nnsal3texcise, nnsal3ttaxamt, nnsal3tvatamt, nnsal3toctroi, nnsal3tfreight, nnsal3tcnamt, nnsal3gadd, nnsal3gless, nnsal3gtbamt ALL
 SELECT inward
 myrepl = ''
 myrepl = myrepl+"Repl totqty With nnsal3tqty"
 myrepl = myrepl+",totamt With nnsal3tamt, netamt With nnsal3tamt, taamt With nnsal3tamt, tbamt With nnsal3gtbamt, plusminamt With nnsal3tplusminamt"
 myrepl = myrepl+",Scheme With nnsal3tscheme, tdamt With nnsal3ttdamt, cdamt With nnsal3tcdamt, excise With nnsal3texcise, taxamt With nnsal3ttaxamt"
 myrepl = myrepl+",vatamt With nnsal3tvatamt, octamt With nnsal3toctroi, freight With nnsal3tfreight"
 myrepl = myrepl+",tless With Scheme+tdamt+cdamt+cnamt+less+tbamt, tadd With excise+taxamt+vatamt+octamt+freight+Add"
 IF plusminamt<0
    myrepl = myrepl+',tless With tless+Abs(plusminamt)'
 ELSE
    myrepl = myrepl+',tadd With tadd+Abs(plusminamt)'
 ENDIF
 myrepl = myrepl+',netamt With totamt+tadd-tless, roff With Round(netamt,0)-netamt, netamt With Round(netamt,0) in inward'
 &myrepl
 SELECT inward
 FLUSH IN inward
 thisform.text5.refresh
 thisform.text6.refresh
 thisform.text7.refresh
 thisform.text8.refresh
 thisform.text9.refresh
 thisform.text10.refresh
 thisform.text13.refresh
 thisform.text14.refresh
 thisform.text16.refresh
 thisform.text18.refresh
 thisform.text20.refresh
 thisform.text24.refresh
 thisform.text25.refresh
 thisform.text27.refresh
 thisform.text32.refresh
 thisform.text34.refresh
 thisform.text37.refresh
 thisform.text39.refresh
 SELECT inward1
 IF salrec<>0 .AND. salrec<=RECCOUNT("inward1")
    GOTO salrec
 endif
 
How to create class or prg from above code ?

Warm regards,
mk.
Jul 20, 2013 at 7:13 AM
I have created a class with above code and dropped this class on my form, now how to run the code using ParallelFox ?

** Created class runaddless
modify class runaddless of runmethod as custom

In runaddless class I have created a method addless and copied the code from addless method of the form.


how to run class method using ParallelFox ?


Warm regards,
mk.
Developer
Jul 25, 2013 at 6:35 PM
mk,

This code will require changes to work with ParallelFox. It's hard for me to say exactly what those should be. Once you understand how ParallelFox works and what it can do for you, you will be in a better position to make those decisions. Let me first ask: Why do you want to run this code in ParallelFox? Does it run slow now? Is that why you want to run it in the background?

Joel
Jul 26, 2013 at 1:14 AM
I have two methods in my form.
  1. thisform.addless()
  2. thisform.sendemail()
When user Click on Save Command Button, It save the record and Send a Email to selected email address.
Now I have to wait for Add Next Entry up to Email sent.

I want to bypass this waiting time by using parallelfox.
** Form.SaveButton.Click()
Thisform.Addless()

**  I want to run this as parallel process.
Thisform.SendEmail()

** I want to run this line without wait for Email sent.
Thisform.Addnew.click()
Warm regards,
mk.
Jul 26, 2013 at 1:37 AM
How to run a VCX Method using ParallelFox ?
** Created class runaddless 
modify class runaddless of runmethod as custom 
In runaddless class I have created method addless and copied the code from addless method of the form.
In runaddless class I have created method SendEmail and copied the code from SendEmail method of the form.

I have Dropped the class on my Form, Now How to run this above two Methods using ParallelFox when user click on SaveButton ?

Which ParallelFox files should we include in setup to run ParallelFox properly ?


Warm regards,
mk.
Developer
Jul 26, 2013 at 2:53 PM
The main thing to keep in mind is that the workers are separate instances of FoxPro, and ParallelFox allows communication between the instances. So, the workers cannot automatically see the "inward" cursor in the main process. You will have to open it in your worker code. Likewise, the workers cannot see "Thisform" from the main process. You should pass any values as parameters to the code you want to run in parallel (you could also pass Thisform to the worker code). I'm not sure where your delays are, but you may be able to get by just running SendEmail() in parallel.

See Parallel.CallMethod() in the Help file for the syntax to run a VCX method. Example:
Parallel.CallMethod("SendEmail", "MyClass", "MyClassLibrary.vcx", "MyApp.exe", .f., MyParameter1, MyParameter2)
To run ParallelFox, include ParallelFox.vcx in your project and register ParallelFox.exe. See the Deployment section in the Help file for more details.

Hope this helps,

Joel
Jul 26, 2013 at 6:29 PM
Thank you,

I will try this and get back to you for further assistant.

Warm regards,
mk.
Jul 26, 2013 at 7:35 PM
Is this compulsory to pass the EXE as parameter ?
can we run the callmethod without EXE parameter ?
Parallel.CallMethod("SendEmail", "runaddless", "runmethod.vcx",, .f., inward.accode,messagetext)
Warm regards,
mk.
Developer
Jul 26, 2013 at 7:46 PM
If you are distributing the VCX inside an EXE or APP, then yes, you need to specify it or ParallelFox won't be able to find the class. If you are using the VCX directly, then the parameter is not required. Alternatively, if you place the class in a PRG instead of VCX, then the EXE/APP parameter is not required.

Joel
Jul 26, 2013 at 7:54 PM
Thank you,

Warm regards,
mk.