473,408 Members | 2,734 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

Web Services, reading standard input and deadlock

I wrote a simple Windows Application based application in C# called the
CallWebServiceGui. This application is started from a different application
called WsGuiStarter. The WsGuiStarter redirects the standard input from the
CallWebServiceGui as a simple method for inter-process communication (IPC)
between the two applications. For the reason of IPC the CallWebServiceGui
creates a new thread, starts it and in it waits for input from standard input.

But if you do such a thing, every call to the WS proxy deadlocks - even the
constructor call to the proxy. So I guess this is a possible bug or me
missing something obvious.

Words can't describe as much as code, so I'm throwing in a couple of code
snippets for the above two solutions.

The CallWebServiceGui code (a simple form with a button that invokes a web
service and a thread that is listening for standard input in IPC means):

public partial class CallWebServiceGui : Form
{
public CallWebServiceGui ()
{
InitializeComponent();
}

private void CallWebServiceGui_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();
// !!! Never gets here !!!
string str = hw.HelloWorld();

MessageBox.Show( str );
}
}

The web service above is the default HelloWorld web service generated by
VS2005 when creating a WS project. Not a single line of code was changed.

Here is also a code snippet for the starting application - the WsGuiStarter.

public partial class WsGuiStarter : Form
{
public WsGuiStarter()
{
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 CallWebServiceGui doesn't have it's standard input redirected it
works perfectly. If it does, it deadlocks. Just for clarity's sake let me say
that the web service URL is correct, the HelloWeb service is running, both
project work, the web service call is not being the reason to block (I know I
have to wait a bit to get the response from a WS). Therefore I'm pointing out
again that the above sample works flawlessly if it doesn't have the standard
input redirected. If it does, it deadlocks.

I'd really like to know if this is a bug or not. Standard input seems like
an elegant and simple way of IPC (communicating between processes) and I
would really like to use it over any other method - for simplicity's sake and
not for me not knowing any other IPC technologies.

So is it a bug or me doing something wrong? I can also share a .zip
containing the whole solution to test the above stuff through.

Thanks!
Miha

Sep 15 '06 #1
0 1320

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: javastudent | last post by:
Hi, I am implementing a server that reads for socket connections at a port, and processes the socket on a separate thread. We do not control the client implementation. Here is the scenario. ...
1
by: fabrice | last post by:
Hello, I've got trouble reading a text file (event viewer dump) by using the getline() function... After 200 - 300 lines that are read correctly, it suddenly stops reading the rest of the...
3
by: Nigel Robbins | last post by:
Hi There, I'm getting a deadlock when I have two clients running the following statement. DELETE FROM intermediate.file_os_details WHERE file_uid = ? AND obj_uid There is a compound index on...
6
by: Gus Tabares | last post by:
Hello, I'm having trouble reading in a character. Here is a snippet of code: int num; char character; printf("Enter a number: "); scanf("%d", &num); printf("You entered %d.\n", num);
2
by: Kyle0654 | last post by:
I've been searching for a solution to this problem for a while but haven't hit upon anything yet. Details: Using: MSVC++ .NET 2003 App type: Windows Forms Application (Managed C++)...
0
by: Lou Evart | last post by:
DOCUMENT CONVERSION SERVICES Softline International (SII) operates one of the industry's largest document and data conversion service bureaus. In the past year, SII converted over a million...
4
by: Dica | last post by:
we just ordered VS 2005 standard edition. i was reading up on creating windows services and apparently this is only possible with the enterprise edition. is this true, or does it simply mean...
3
by: bob_jeffcoat | last post by:
Hi, I'm trying to read the output and write the input of a process using its StandardOutput/Input and I'd really like to check if the process is waiting for input or whether it has output ready...
3
by: NaN | last post by:
Hi I'm using Dev-C++. Here is my sourcecode. /* GETCH.C: This program reads characters from * the keyboard until it receives a 'Y' or 'y'. */ #include <conio.h>
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.