[Gambas-user] Problem to use TASK fork processes

Benoît Minisini gambas at ...1...
Tue Apr 2 23:49:22 CEST 2013


Le 01/04/2013 19:01, Olivier Cruilles a écrit :
> Hi Benoit,
>
> I have just question about how to use the TASK (fork process) and particularly how to return value from the TASK to the parent.
>
> I used all possibilities but nothing solve my problem, sometimes the parent of the Task(es) loses retourned value from the TASK.
>
> I send result from to the parent like that, it is good or not.
>
> -----------------------------
>
> 1st methode:
>
> At the end of the Main() procedure of the TASK
>
>    PRINT "RESULT" & Chr(140) & $Numero & Chr(140) & Resultat
>
> Into the parent:
>
> Procedure ProcStat_Read(Data as string)
>
> 	Print "(" & Str(LAST) & ")  Data: " & Data
>
> End
>
> -----------------------------
>
> 2nd methode:
>
> At the end of the Main() procedure of the TASK
>
>    WRITE #1, "RESULT" & Chr(140) & $Numero & Chr(140) & Resultat
>
> Into the parent:
>
> Procedure ProcStat_Read(Data as string)
>
> 	Print "(" & Str(LAST) & ")  Data: " & Data
>
> End
>
> -----------------------------
>
> The gold of this program is to start many TASKs simultaneously to gain time but in fact it works better with 10 TASKs
> simultaneously and not very well with 1 TASK
> So how can be sure that the TASK sent me the result all of the time please ?
>
> Does I don't use the TASK object correctly ?
>
> Thank's in advance.
>
> Cordialement,
>
> Olivier Cruilles
> Mail: linuxos at ...1896...
>

Without the source code to test, it's hard to tell...

I don't know how you ends your tasks, and so I think that your task 
terminates before the data printed on the standard output reaches the 
parent process.

Note that normally you must return the result of the task to the parent 
process by *returning* a value from the Main fuction. That return value 
can be any Variant, not just an integer like a normal process.

Regards,

-- 
Benoît Minisini




More information about the User mailing list