tags:

views:

46

answers:

3

Hi,

I have a WCF webservice using the WebServiceHost class.

new WebServiceHost(typeof(MyServiceClass));

If I use a blocking call like Thread.Sleep (just an example) in one of my webservice methods and i call this method the whole service is not usable while the blocking call is active.

Is that normal behaviour or is there an error somewhere in my configuration or usage?

+1  A: 

What's the InstanceContextMode and ConcurrencyMode settings on your service? If it's set to Single then there's only one instance of your service and all the calls are queued so if you put the service thread to sleep it will block all subsequent calls.

For example:

[ServiceBehavior(InstanceContextMode = InstanceContextMode.Single,
                 ConcurrencyMode = ConcurrencyMode.Single)]
public class MyService : IMyService
{
}
theburningmonk
A: 

Thanks burning monk, i searched through my project for your given keywords, 0 hits.

I tried the example from this page: http://blogs.msdn.com/b/justinjsmith/archive/2007/07/02/webservicehost-vs-servicehost.aspx which does NOT have this problem.

The only difference I found is that it does the configuration in code, in my application its in app.config.

I'm sure i'll find the mistake with enough time. ;-)

@Kirl Woll: I used it only for simulating a lengthy, blocking operation.

huhu
A: 

It seems to have something to do if the host application is a console or windows forms applications!!

Console application => works fine, not blocking the whole service

Windows forms application => blocks whole service

I used the same (minimalistic) code for both test applications.

Edit: When I Open() the WebServiceHost in a new thread in the windows forms application it now also works fine. But I don't get it - why does it work in a console application without an additional thread?

huhu