Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get return value from process

Tags:

c#

process

Hi I am trying to do the following: I have a process which can take parameters (digits) and return the sum of these numbers

Process P = Process.Start(sPhysicalFilePath, Param);                 int result = P.ExitCode; 

I get the return value from "ExitCode" the problem is: the program sometimes finishes his work before the process so when the program reaches this line

int result = P.ExitCode; 

I got an exception .. my question is how to wait this process until it finishes its work sorry I forget to say that's I am working with C# language

like image 687
Hany Avatar asked Oct 18 '09 16:10

Hany


People also ask

How can we get return value from multiprocessing process?

To get the return value of a function passed to Python multiprocessing. Process, we can use the manager. dict method to create a shared variable. to create a Process object with the target set to the worker function that runs for each process.

How do you do multiprocessing in Python?

In this example, at first we import the Process class then initiate Process object with the display() function. Then process is started with start() method and then complete the process with the join() method. We can also pass arguments to the function using args keyword.


1 Answers

use:

Process P = Process.Start(sPhysicalFilePath, Param); P.WaitForExit(); int result = P.ExitCode; 

from MSDN

like image 79
snicker Avatar answered Oct 31 '22 21:10

snicker