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 6206923
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T05:32:14+00:00 2026-05-24T05:32:14+00:00

I will go ahead and preface this by saying: I am somewhat new to

  • 0

I will go ahead and preface this by saying: I am somewhat new to WCF.

I’m working on a server-side routine that’s responsible for doing a great deal of business logic. It’s accessible from a client via WCF.

My main WCF method calls off to several other private methods. Instead of passing around all of the “lookup data” I need for the business logic to each private method, I decided to use a singleton instance of a class named DataProvider that contains all of this “lookup data”.

At the end of the routine, I “release” the DataProvider’s lookup data so the next time the routine is executed, the latest lookup data will be used.

So, here’s a simplified example:

 public void Generate()
 {
      try
      {
           //populate singleton DataProvider with it's lookup data...
           DataProvider.Instance.LoadLookupData();

           //do business logic...
      }
      finally
      {
           //release provider's lookup data...
           DataProvider.Release();
      }
 }

This works great until I have two different clients that execute the method at (or near) the same time. Problems occur because they share the same singleton instance and the task who finishes first will release the DataProvider before the other completes.

So…

What are my options here?

I’d like to avoid passing around all of the lookup data so the singleton pattern (or some derivative) seems like a good choice. I also need to be able to support multiple clients calling the method at the same time.

I believe the WCF service is configured as “Per-Call”. I’m not sure if there’s a way to configure a WCF service so that the static memory is not shared between service invocations.

Any help would be appreciated.

  • 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-24T05:32:14+00:00Added an answer on May 24, 2026 at 5:32 am

    By default WCF is using “Per-Call”, which means new instance of the WCF service is created for each client’s call. Now since you implemented singleton even though new instance of the WCF is created it still calls your singleton.

    If you would like to create lookup that is created for each call (like you have now) you should not do it as singleton. This way each client that calls your method will have new instance of the lookup, I think that was your intention.

    However if you have lookup that is not changing that fast, I would recommend to share it between all calls, this will improve performance of your WCF service. You will need to declare your WCF service as

    InstanceContextMode = InstanceContextMode.Single
    ConcurrencyMode = ConcurrencyMode.Multiple  
    

    What this does is creating Singleton automatically for you by WCF, so you don’t have to do it yourself, second it will support > 1 concurrent user (ConcurrencyMode.Multiple).

    Now if you have your lookup that is changing and it needs to be reloaded after some period of time, I still would recommend using

    InstanceContextMode = InstanceContextMode.Single 
    ConcurrencyMode = ConcurrencyMode.Multiple
    

    but inside in your code cache it and then expire your cache at specific time or relative time (1 hours).

    Here are some links that might help you:
    3 ways to do WCF instance management (Per call, Per session and Single)

    Hope this will help.

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

Sidebar

Related Questions

Looking ahead in the likely event we will build a server farm rather than
This one is stumping me, I will just go ahead and explain via SQL.
I'm building several jQuery plugin and going ahead I thought that will be useful
I'm working on an ipad webapp that will receive monthly changes. However I can
Doing a custom Tumblr theme that will have a mix of the usual Tumblr
I'm currently working on an app that will need to upload images to an
Will the code below work if the clock on the server is ahead of
I'm really thinking that in the years ahead, I will be creating internal apps
Will the following code cause a ConcurrentModificationException or other side effects? ArrayList<String> newList =
Will the events that I added to the global event bus deleted by calling

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.