I have a C# 2008 console application that calls another C# console application using a process.start command. The second C# program calls a web service.
The first console application calls the second console application with calls in a specific order. This is required since the calls to the web service need to occur in a certain order.
Due to the facts that I just listed, I have the following questions to ask:
1. I would like to know how I can make the first program wait for a response from the second C# application. This wait need needs to occur before the next call is made to the web service.
2. Is there a way that I can pass the return code value from the web service (called by the second program) to the first program? If so, how would I accomplisht this goal?
Thus can you tell me and/or point me to a refernces on how I can accomplish my goals?
If this is not possibly, I do have a tracking database table setup for making certain each phase of the calls to the web service occur.
Let me know what you think the best solution would be.
Loading
EhteshamPosted Oct 14, 2012, 4:49 AM
you can refer dll method to call a web service and get the returned value. That will be simple and right way to do it.
if you still want to go with .exe use ProcessInstanceObj.MainModule.GetType().GetMethod("YourMethodName").Invoke
Nitesh KejriwalPosted Oct 14, 2012, 3:34 AM
dcPosted Oct 13, 2012, 3:27 PM
Your code will work except, I want the return code of the web service that is called by the second console application. I do not care about the return code fromnthe second console application.
Thus can you tell me how first console application can obtain the return code from the web service that is called by the second console application?
EhteshamPosted Oct 13, 2012, 1:10 PM
method,in the second console application make use of the below
code.
System.Diagnostics.Process p = new System.Diagnostics.Process();
p.StartInfo.UseShellExecute = false;
p.StartInfo.FileName = YOURFIRSTCONSOLEAPP.EXE;
p.Start();
//this will wait till your first console application finishes execution
p.WaitForExit();
int returnCode = p.ExitCode;
ExiCode property of Process class catches the return value of a
process.i.e in your case it will be process of first console
application
Hope this helps, Happy Coding :-)
Nitesh KejriwalPosted Oct 13, 2012, 3:12 AM