C
Crnjan
Hello!
I recently found a strange phenomenon. I am using a simple Windows
Application based application written in C# (lets name it
TestWebServiceStrangePhenomenom). The TestWebServiceStrangePhenomenom
application is started from another application which also redirects
standard input from TestWebServiceStrangePhenomenom. The
TestWebServiceStrangePhenomenom creates a new thread and within it,
waits for input from app that started it (the redirected standard input
stream is used for IPC). And now comes the strange part: if I add a new
button to windows form and in the click action call some web service,
the web service deadlocks!!!
I wrote a simple demo application to demonstrate the problem.
The TestWebServiceStrangePhenomenom code:
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
new Thread( new ThreadStart( WaitForInput ) ).Start();
// Give thread time to start...
Thread.Sleep( 200 );
}
private void WaitForInput ()
{
Stream stdin = Console.OpenStandardInput();
// Wait for input...
int rv = stdin.ReadByte();
}
private void buttonHelloWorld_Click(object sender, EventArgs e)
{
// !!! Deadlock HERE !!!
HelloWorld.Service hw = new
TestWebService.HelloWorld.Service();
string str = hw.HelloWorld();
MessageBox.Show( str );
}
}
For the web service I used the default ASP.Net Web Service sample
(HelloWorld) that is automaticaly generated within VS2005.
And also the code for starting the TestWebServiceStrangePhenomenom
(another project):
public partial class mainForm : Form
{
public mainForm()
{
InitializeComponent();
}
private void buttonBrowse_Click(object sender, EventArgs e)
{
if ( openFileDialog.ShowDialog() == DialogResult.OK )
textBoxPath.Text = openFileDialog.FileName;
}
Process process = new Process();
private void buttonRun_Click(object sender, EventArgs e)
{
process.StartInfo.UseShellExecute = false;
process.StartInfo.RedirectStandardInput = true;
process.StartInfo.FileName = textBoxPath.Text;
process.StartInfo.WindowStyle = ProcessWindowStyle.Normal;
process.Start();
}
}
If the TestWebServiceStrangePhenomenom has not got the input stream
redirected, than the web service will work!
I recently found a strange phenomenon. I am using a simple Windows
Application based application written in C# (lets name it
TestWebServiceStrangePhenomenom). The TestWebServiceStrangePhenomenom
application is started from another application which also redirects
standard input from TestWebServiceStrangePhenomenom. The
TestWebServiceStrangePhenomenom creates a new thread and within it,
waits for input from app that started it (the redirected standard input
stream is used for IPC). And now comes the strange part: if I add a new
button to windows form and in the click action call some web service,
the web service deadlocks!!!
I wrote a simple demo application to demonstrate the problem.
The TestWebServiceStrangePhenomenom code:
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
new Thread( new ThreadStart( WaitForInput ) ).Start();
// Give thread time to start...
Thread.Sleep( 200 );
}
private void WaitForInput ()
{
Stream stdin = Console.OpenStandardInput();
// Wait for input...
int rv = stdin.ReadByte();
}
private void buttonHelloWorld_Click(object sender, EventArgs e)
{
// !!! Deadlock HERE !!!
HelloWorld.Service hw = new
TestWebService.HelloWorld.Service();
string str = hw.HelloWorld();
MessageBox.Show( str );
}
}
For the web service I used the default ASP.Net Web Service sample
(HelloWorld) that is automaticaly generated within VS2005.
And also the code for starting the TestWebServiceStrangePhenomenom
(another project):
public partial class mainForm : Form
{
public mainForm()
{
InitializeComponent();
}
private void buttonBrowse_Click(object sender, EventArgs e)
{
if ( openFileDialog.ShowDialog() == DialogResult.OK )
textBoxPath.Text = openFileDialog.FileName;
}
Process process = new Process();
private void buttonRun_Click(object sender, EventArgs e)
{
process.StartInfo.UseShellExecute = false;
process.StartInfo.RedirectStandardInput = true;
process.StartInfo.FileName = textBoxPath.Text;
process.StartInfo.WindowStyle = ProcessWindowStyle.Normal;
process.Start();
}
}
If the TestWebServiceStrangePhenomenom has not got the input stream
redirected, than the web service will work!