pause a process in C and free it from C#

G

Gidi

Hi,

My C# windows application is running another process which is a c (language)
binary.

the c binary prints output to the screen which i want to catch in my C#
program.

I know how to run the binary with the Process class, what's i'm missing now,
is that after each output print in my binary i want to wait till my C#
program will tell the binary to continue.

I guess i should use wait() or something like that in my c program, and free
it from my C# program.

how can it be done?

here is my process initialization:

c_Process = new Process();
ProcessStartInfo psI = new ProcessStartInfo();
psI.FileName = @"D:\gidi.bat"
psI.UseShellExecute = false;
psI.RedirectStandardInput = true;
psI.RedirectStandardOutput = true;
psI.RedirectStandardError = true;
psI.CreateNoWindow = true;
c_Process.StartInfo = psI;
c_Process.Start();

Thanks,
Gidi.
 
N

Nicholas Paldino [.NET/C# MVP]

Gidi,

You are better off using a synchronization method that can be shared
between the two processes. Typically, you would want to use a named event,
which you can access in your C program (through the Windows API) and in .NET
(through the System.Threading namespace).

What you would do is have your C# program Set the event, while the C
program would wait on it.
 
G

Gidi

Hi Nicholas,

Thanks again for your help.

I admit that I've no experince with threading synchronization.

if it's not too hard, i'll love to get an example.

in the meanwhile i will try to google it and learn about it.

Thanks,
Gidi.

Nicholas Paldino said:
Gidi,

You are better off using a synchronization method that can be shared
between the two processes. Typically, you would want to use a named event,
which you can access in your C program (through the Windows API) and in .NET
(through the System.Threading namespace).

What you would do is have your C# program Set the event, while the C
program would wait on it.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)


Gidi said:
Hi,

My C# windows application is running another process which is a c
(language)
binary.

the c binary prints output to the screen which i want to catch in my C#
program.

I know how to run the binary with the Process class, what's i'm missing
now,
is that after each output print in my binary i want to wait till my C#
program will tell the binary to continue.

I guess i should use wait() or something like that in my c program, and
free
it from my C# program.

how can it be done?

here is my process initialization:

c_Process = new Process();
ProcessStartInfo psI = new ProcessStartInfo();
psI.FileName = @"D:\gidi.bat"
psI.UseShellExecute = false;
psI.RedirectStandardInput = true;
psI.RedirectStandardOutput = true;
psI.RedirectStandardError = true;
psI.CreateNoWindow = true;
c_Process.StartInfo = psI;
c_Process.Start();

Thanks,
Gidi.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top