Windows Vista Forums
Vista Forums Home Join Vista Forums Donate Vista Tutorials Tags

Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
Register at Vista forums...the world biggest Windows Vista resource Join Vista Forums Now

Go Back   Vista Forums > Microsoft Technical Newsgroups > Indigo

Multithreading in WCF Service

Update your Vista Drivers Update Your Drivers Now!!
 
 
Thread Tools Display Modes
Old 06-14-2007   #1 (permalink)
Markus Strobl
Guest


 

Multithreading in WCF Service

Hi!

Can anybody tell me how to turn on multithreading in a Singleton WCF
service?

Currently only one operation executes after the other and all the other
clients have to wait until the currently executing operation has completed.

Any help would be greatly appreciated!

Thanks a lot in advance!

Markus



My System SpecsSystem Spec
Old 06-14-2007   #2 (permalink)
ronscottlangham@yahoo.com
Guest


 

Re: Multithreading in WCF Service

On Jun 14, 6:51 am, "Markus Strobl" <m.str...@nospam.nospam> wrote:
> Hi!
>
> Can anybody tell me how to turn on multithreading in a Singleton WCF
> service?
>
> Currently only one operation executes after the other and all the other
> clients have to wait until the currently executing operation has completed.
>
> Any help would be greatly appreciated!
>
> Thanks a lot in advance!
>
> Markus


I haven't actually played around with this myself, but I believe this
is controlled by the ServiceBehavior ConcurrencyMode. By default it
is Single and now allowing re-entrancy. You may try Multiple e.g.

[ServiceBehavior(ConcurrencyMode = ConcurrencyMode.Multiple)]
public class MyService : IMyService
{

But, you are saying that it is not re-entrant from other clients. I
was under the impression that if from different clients that the
Service was by default able to handle multiple clients and not
block. The Multiple mode is used then to allow re-entrancy from the
same client in this case. A WCF service by default would allow re-
entrancy from multiple clients up to the MaxConnections property of
the binding configuration, or I believe may also be controlled by IIS
configuration.

Did you specify a different InstanceContextMode, or using the
default? e.g.

[ServiceBehavior(InstanceContextMode =
InstanceContextMode.PerSession)]
public class MyService : IMyService

I think the default is PerSession and allows the re-entrancy by
multiple clients. But, if was changed to InstanceContextMode.Single
then you would see the issue with one client blocking the other since
they are sharing the same service instance.

Ron

My System SpecsSystem Spec
Old 06-14-2007   #3 (permalink)
Markus Strobl
Guest


 

Re: Multithreading in WCF Service

Hi Ron,

thanks a lot for your reply!!

Applying the Attribute [ServiceBehavior(ConcurrencyMode =
ConcurrencyMode.Multiple)] made it work!

I had to keep InstanceContextMode at InstanceContextMode.Single as i'm
exposing a Singleton object and InstanceContextMode.Single is required for
this pattern.

Thanks again and Best wishes

Markus



<ronscottlangham@yahoo.com> schrieb im Newsbeitrag
news:1181823085.263375.229910@a26g2000pre.googlegroups.com...
> On Jun 14, 6:51 am, "Markus Strobl" <m.str...@nospam.nospam> wrote:
>> Hi!
>>
>> Can anybody tell me how to turn on multithreading in a Singleton WCF
>> service?
>>
>> Currently only one operation executes after the other and all the other
>> clients have to wait until the currently executing operation has
>> completed.
>>
>> Any help would be greatly appreciated!
>>
>> Thanks a lot in advance!
>>
>> Markus

>
> I haven't actually played around with this myself, but I believe this
> is controlled by the ServiceBehavior ConcurrencyMode. By default it
> is Single and now allowing re-entrancy. You may try Multiple e.g.
>
> [ServiceBehavior(ConcurrencyMode = ConcurrencyMode.Multiple)]
> public class MyService : IMyService
> {
>
> But, you are saying that it is not re-entrant from other clients. I
> was under the impression that if from different clients that the
> Service was by default able to handle multiple clients and not
> block. The Multiple mode is used then to allow re-entrancy from the
> same client in this case. A WCF service by default would allow re-
> entrancy from multiple clients up to the MaxConnections property of
> the binding configuration, or I believe may also be controlled by IIS
> configuration.
>
> Did you specify a different InstanceContextMode, or using the
> default? e.g.
>
> [ServiceBehavior(InstanceContextMode =
> InstanceContextMode.PerSession)]
> public class MyService : IMyService
>
> I think the default is PerSession and allows the re-entrancy by
> multiple clients. But, if was changed to InstanceContextMode.Single
> then you would see the issue with one client blocking the other since
> they are sharing the same service instance.
>
> Ron
>



My System SpecsSystem Spec
Old 06-14-2007   #4 (permalink)
Jon Davis
Guest


 

Re: Multithreading in WCF Service

Wow, I overlooked this. I had assumed that a WCF singleton was always
blocking, single-threaded.


... but at
http://msdn.microsoft.com/msdnmag/is...s/default.aspx ..

"Having a singleton implies the singleton has some valuable state that you
want to share across multiple clients. The problem is that when multiple
clients connect to the singleton, they may all do so concurrently on
multiple worker threads."

Rawk! Problem? All your service variables are static. Fine, I was using
static variables anyway.

Jon

"Markus Strobl" <m.strobl@nospam.nospam> wrote in message
news:uHQWLborHHA.4764@TK2MSFTNGP06.phx.gbl...
> Hi Ron,
>
> thanks a lot for your reply!!
>
> Applying the Attribute [ServiceBehavior(ConcurrencyMode =
> ConcurrencyMode.Multiple)] made it work!
>
> I had to keep InstanceContextMode at InstanceContextMode.Single as i'm
> exposing a Singleton object and InstanceContextMode.Single is required for
> this pattern.
>
> Thanks again and Best wishes
>
> Markus
>
>
>
> <ronscottlangham@yahoo.com> schrieb im Newsbeitrag
> news:1181823085.263375.229910@a26g2000pre.googlegroups.com...
>> On Jun 14, 6:51 am, "Markus Strobl" <m.str...@nospam.nospam> wrote:
>>> Hi!
>>>
>>> Can anybody tell me how to turn on multithreading in a Singleton WCF
>>> service?
>>>
>>> Currently only one operation executes after the other and all the other
>>> clients have to wait until the currently executing operation has
>>> completed.
>>>
>>> Any help would be greatly appreciated!
>>>
>>> Thanks a lot in advance!
>>>
>>> Markus

>>
>> I haven't actually played around with this myself, but I believe this
>> is controlled by the ServiceBehavior ConcurrencyMode. By default it
>> is Single and now allowing re-entrancy. You may try Multiple e.g.
>>
>> [ServiceBehavior(ConcurrencyMode = ConcurrencyMode.Multiple)]
>> public class MyService : IMyService
>> {
>>
>> But, you are saying that it is not re-entrant from other clients. I
>> was under the impression that if from different clients that the
>> Service was by default able to handle multiple clients and not
>> block. The Multiple mode is used then to allow re-entrancy from the
>> same client in this case. A WCF service by default would allow re-
>> entrancy from multiple clients up to the MaxConnections property of
>> the binding configuration, or I believe may also be controlled by IIS
>> configuration.
>>
>> Did you specify a different InstanceContextMode, or using the
>> default? e.g.
>>
>> [ServiceBehavior(InstanceContextMode =
>> InstanceContextMode.PerSession)]
>> public class MyService : IMyService
>>
>> I think the default is PerSession and allows the re-entrancy by
>> multiple clients. But, if was changed to InstanceContextMode.Single
>> then you would see the issue with one client blocking the other since
>> they are sharing the same service instance.
>>
>> Ron
>>

>
>



My System SpecsSystem Spec
Old 06-15-2007   #5 (permalink)
ronscottlangham@yahoo.com
Guest


 

Re: Multithreading in WCF Service

On Jun 14, 2:14 pm, "Jon Davis" <j...@REMOVE.ME.PLEASE.jondavis.net>
wrote:
> Wow, I overlooked this. I had assumed that a WCF singleton was always
> blocking, single-threaded.
>
> .. but athttp://msdn.microsoft.com/msdnmag/issues/06/06/wcfessentials/default......
>
> "Having a singleton implies the singleton has some valuable state that you
> want to share across multiple clients. The problem is that when multiple
> clients connect to the singleton, they may all do so concurrently on
> multiple worker threads."
>
> Rawk! Problem? All your service variables are static. Fine, I was using
> static variables anyway.
>
> Jon
>
> "Markus Strobl" <m.str...@nospam.nospam> wrote in message
>
> news:uHQWLborHHA.4764@TK2MSFTNGP06.phx.gbl...
>
> > Hi Ron,

>
> > thanks a lot for your reply!!

>
> > Applying the Attribute [ServiceBehavior(ConcurrencyMode =
> > ConcurrencyMode.Multiple)] made it work!

>
> > I had to keep InstanceContextMode at InstanceContextMode.Single as i'm
> > exposing a Singleton object and InstanceContextMode.Single is required for
> > this pattern.

>
> > Thanks again and Best wishes

>
> > Markus

>
> > <ronscottlang...@yahoo.com> schrieb im Newsbeitrag
> >news:1181823085.263375.229910@a26g2000pre.googlegroups.com...
> >> On Jun 14, 6:51 am, "Markus Strobl" <m.str...@nospam.nospam> wrote:
> >>> Hi!

>
> >>> Can anybody tell me how to turn on multithreading in a Singleton WCF
> >>> service?

>
> >>> Currently only one operation executes after the other and all the other
> >>> clients have to wait until the currently executing operation has
> >>> completed.

>
> >>> Any help would be greatly appreciated!

>
> >>> Thanks a lot in advance!

>
> >>> Markus

>
> >> I haven't actually played around with this myself, but I believe this
> >> is controlled by the ServiceBehavior ConcurrencyMode. By default it
> >> is Single and now allowing re-entrancy. You may try Multiple e.g.

>
> >> [ServiceBehavior(ConcurrencyMode = ConcurrencyMode.Multiple)]
> >> public class MyService : IMyService
> >> {

>
> >> But, you are saying that it is not re-entrant from other clients. I
> >> was under the impression that if from different clients that the
> >> Service was by default able to handle multiple clients and not
> >> block. The Multiple mode is used then to allow re-entrancy from the
> >> same client in this case. A WCF service by default would allow re-
> >> entrancy from multiple clients up to the MaxConnections property of
> >> the binding configuration, or I believe may also be controlled by IIS
> >> configuration.

>
> >> Did you specify a different InstanceContextMode, or using the
> >> default? e.g.

>
> >> [ServiceBehavior(InstanceContextMode =
> >> InstanceContextMode.PerSession)]
> >> public class MyService : IMyService

>
> >> I think the default is PerSession and allows the re-entrancy by
> >> multiple clients. But, if was changed to InstanceContextMode.Single
> >> then you would see the issue with one client blocking the other since
> >> they are sharing the same service instance.

>
> >> Ron


Probably known, but I will mention anyway. You need to make sure that
you server code is thread-safe and you have locks and other
multithreading protection around your variables, objects, etc.

My System SpecsSystem Spec
 

Thread Tools
Display Modes



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to install service to bypass Vista Interactive Services Detection Service kianlie84 Vista security 0 08-28-2008 02:25 AM
Vista Multithreading, lack thereof ??? David Jones Vista performance & maintenance 2 06-01-2007 10:51 AM
Multithreading gaurhoth PowerShell 4 11-26-2006 01:42 PM
multithreading? JamesPang PowerShell 1 11-20-2006 07:58 AM


Vistax64.com is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media 2005-2008

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51