Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3341444
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T00:43:24+00:00 2026-05-18T00:43:24+00:00

Say I have a WCF service that has access to some data that is

  • 0

Say I have a WCF service that has access to some data that is shared between multiple clients. What is the difference between these two setups:

1) Instancing: Single, Concurrency: Multiple, with the shared data stored in instance variables.

2) Instancing: Per-Call, Concurrency: Multiple, with the shared data stored in static variables.

Is there any practical difference? Either way, I will have to make sure the shared data is thread-safe, but I’m wondering if there are any advantages for one particular approach.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T00:43:25+00:00Added an answer on May 18, 2026 at 12:43 am

    Notionally, there is no difference. As you’ve said, either way you’re gonna have to synchronize access to the shared data. Practically, the second option is better. From the definitive book on WCF, Programming WCF Services by Juval Lowy:

    …per-call services are actually the
    preferred instance management mode for
    WCF services…recommend that you
    avoid singletons in the general case
    and find ways to share the state of
    the singleton instead of the singleton
    instance itself.

    I use option #2 for my project. The WCF service itself is simply a thin facade to static methods of the classes where the work is performed. For example,

    public class Logger
    {
        private static List<Logger> _loggers = new List<Logger>();
        private static object _sync = new object();
    
        public static void Start()
        {
            Logger logger = new Logger();
            logger.Start();
    
            lock (_sync) {
                _loggers.Add( logger );
            }
        }
    
        private Logger()
        {
            // construct the Logger object...
        }
    
        private void Start()
        {
            // start the logger here...
        }
    }
    
    public class LoggingService : ILoggingService
    {
        public void StartLogger()
        {
            Logger.Start();
        }
    }
    

    Obviously, I’ve elided many of the details, but this shows the general idea.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say I have a WCF service which has a method returning object Person.
Lets say I have a WCF service that a client can use to receive
I have a WCF service that uses ODP.NET to read data from an Oracle
We have a WCF service that has a threshold of 30MB to send files
I have a WCF service that has a few different responsibilities, but it provides
I have made an App that connects to a WCF service and checks every
I have a WCF service that uses the entity framework to retrieve records from
I have a WCF Service that exposes two endpoints. One with a WebHttpBinding (acting
Let's say that I'm considering designing a WCF service whose primary purpose is to
I have a WCF service which exposes a Generic interface (and the service has

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.