Click here to Skip to main content
15,880,608 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Good evening,
I just experienced a strange problem that I just can not understand.
I have a WCF service that can receive messages (string). Very simple, right out of the book.
The client sends the message to the service which works fine.

Here comes the strange part:
I added a MessageBox to the form hosting the service that pops up and displays the received message(simple string).
Everything seems to work like a charm.
Then I reduced the received timeout to 5 sec. and left the messagebox accidentally open (grabbing fresh coffee), which caused the client to throw a timeout exception after 5 sec.
I just never noticed this, because the timeout was 60sec before and I never left the MessageBox open that long.

When I write to the console instead of opening the messagebox everything works again like it never happened...

What is happening here... does the MessageBox somehow blocks the client sending the message or something like that(I hope I do not leave a totally stupid implression *LG*)?
I am just curious whats going on here, maybe someone can be so kind and explain this to me ;)

I know that a MessageBox blocks the application, but I didn't expected it to cause a timeout on the client when shown by the service-host.

have a great evening and best regards
Andy
Posted
Updated 10-Nov-10 6:29am
v2
Comments
dan!sh 10-Nov-10 16:11pm    
Can you some code, it might help.
hoernchenmeister 11-Nov-10 2:35am    
The project I am working on is splitted into three parts. The first one wrapps up the service (initializes it and handles lifetime) and fires an event (maybe that is important) if a message is received, the second one is a static class with a static method to be called to send the message.
The last part is an application that hosts the service-host and has subscribed to the event fired by the service-host.
So if the service-host raises the IncomingMessageReceived event the app fires the MessageBox(Console.WriteLine).
that's the app-code so far:
private InterAppMessageHandler _interAppMessageHandler = InterAppMessageHandler.Factory(); //returnes an instance of the MessageHandler (service-host)
interAppMessageHandler.IncomingMessageReceived += interAppMessageHandlerIncomingMessageReceived;

void interAppMessageHandlerIncomingMessageReceived(object sender, string msg)
{
MessageBox.Show(msg);
Console.WriteLine(msg);
}

The sending application (different form) just calls the static method:
InterAppMessageSender.SendMessage("some text");

What might be important is that if I send the message like this:
Task.Factory.StartNew(() => InterAppMessageSender.SendMessage(msg));
I do not get any problems at all, even with the messagebox...

If you added a MessageBox to the service, of course it's going to fail! MessageBox is a blocking call and won't let any code execute until the dialog is dismissed, even the service code.
 
Share this answer
 
Comments
hoernchenmeister 11-Nov-10 2:21am    
So this happens even if the service does not return anything?
What makes me wondering was that the timeout happened on the client. I didn't expect that the service that received the call successfully and does not return anything causes such a behavior.
Just because the service doesn't return a value doesn't mean that it can't return a "call complete" status.
 
Share this answer
 
Comments
hoernchenmeister 11-Nov-10 7:58am    
Yes, that definitely makes sense...
Thanks for pointing this out, I really appreciate it.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900