how avoids deadlock condition

Posted by rima on Stack Overflow See other posts from Stack Overflow or by rima
Published on 2010-05-19T08:59:00Z Indexed on 2010/05/19 9:00 UTC
Read the original article Hit count: 302

Filed under:
|
|

Hi I try to write a program like a compiler.In this case I must simulate these codes of SQLPL(This one can be just for example).for example in command prompt i wana do these:

c:\> sqlplus
 ....
Enter User-Name:(here we must enter username) xxxx
Enter password:(same up)yyyyy
...
sql>(now i want to send my sql command to shell)prompt "rima";
"rima"  [<-output]
sql> prompt "xxxx"
sql> exit

very simple. I try to use this code:

ProcessStartInfo psi = new ProcessStartInfo(
@"sqlplus");
psi.UseShellExecute = false;
psi.CreateNoWindow = true;
psi.RedirectStandardInput = true;
psi.RedirectStandardOutput = true;
//psi.RedirectStandardError = true;
Process process = new Process();
process.StartInfo = psi;
bool started = process.Start();
if (started)
{
process.StandardInput.WriteLine("user/password");
process.StandardInput.Flush();
string ret = process.StandardOutput.ReadLine(); // <-- stalls here
System.Console.WriteLine("sqlplus says :" + ret + "\".");
}

i find out it form here but as if u read this code has problem!DEADLOCK Condition problem! this is my second time i ask my question,every time my knowledge growing,but i cant get how I can solve my problem at last!!!

So I kindly kiss your hand,please help me,these process is not clear for me.any one can give me a code that handle my problem?Already i look at all codes,also I try to use ProcessRunner that in my last post some one offer me,but I cant use it also,i receive an error.

I hope by first example u find out what i want,and solve the second code problem...
thanks
I use C# for implemantation

© Stack Overflow or respective owner

Related posts about deadlock

Related posts about condition