![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
| |
| | #1 (permalink) |
| | 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 Specs![]() |
| | #2 (permalink) |
| | 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 Specs![]() |
| | #3 (permalink) |
| | 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 Specs![]() |
| | #4 (permalink) |
| | 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 Specs![]() |
| | #5 (permalink) |
| | 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 Specs![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| The system event notification service service failed logon ... token does not exist | General Discussion | |||
| Vista Multithreading, lack thereof ??? | Vista performance & maintenance | |||
| Multithreading | PowerShell | |||
| multithreading? | PowerShell | |||