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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T04:56:43+00:00 2026-05-16T04:56:43+00:00

If a WCF Service gets the same request, means the same MD5 over all

  • 0

If a WCF Service gets the same request, means the same MD5 over all Parameters i want to block all except the first request until the processing is done and notify all waiting clients.

What is the best way doing this? I thaugh of something like a channel sink, maybe there is a finnished implementation for archieving this?

  • 1 1 Answer
  • 1 View
  • 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-16T04:56:44+00:00Added an answer on May 16, 2026 at 4:56 am

    I’m not sure about what would be the ‘best’ fit for the WCF architecture but you should consider setting your InstanceContextMode to Single as you’re likely to be doing a lot of synchronization steps for what you want to do here.

    How about something like this? You will obviously need to do some synchronization on the dictionary itself, but at least it’s a start.

    private IDictionary<string, RequestToken> RequestTokens = 
       new Dictionary<string, RequestToken>();
    
    public MyResponse MyMethod(MyRequest request)
    {
       // get the MD5 for the request
       var md5 = GetMD5Hash(request);
    
       // check if another thread is processing/has processed an identical request
       RequestToken token;
       if (RequestTokens.TryGetValue(md5, out token))
       {
          // if the token exists already then wait till we can acquire the lock
          // which indicates the processing has finished and a response is ready
          // for us to reuse
          lock (token.Sync)
          {
             return token.Response;
          }
       }
       else
       {
          var token = new Token(md5);
          lock (token.Sync)
          {
             RequestTokens.Add(md5, token);
    
             // do processing here..
             var response = ....
    
             token.Response = response;
    
             return response;
          }
       }
    }
    
    private class RequestToken
    {
       private readonly object _sync = new object();
    
       public RequestToken(string md5)
       {
          MD5 = md5;
       }
    
       public string MD5 { get; private set; }
    
       public object Sync { get { return _sync; } }
    
       public MyResponse Response { get; set; }
    }
    

    To me, this is something I’d want to abstract away from my business logic, and I’ll personally use PostSharp and write a little attribute to handle all this.

    I’ve written a Memoizer attribute which does something similar in the lines of caching responses based on request but without the synchronization steps, so you could probably take a look at what I’ve done and modify it accordingly to achieve what you’re after.

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

Sidebar

Related Questions

We have an asynchronous WCF service operation that gets log files from all of
I have a C# WCF service DLL that gets hosted by WcfSvcHost.exe when I
I've WCF Service that response with JSON. I want to get the JSON String
I have implemented a SQL Membership provider for my WCF service. The service gets
Is there an event that fires when a WCF service gets started or shut
My WCF service uses callbacks. To be able to call all clients, I'm using
Imagine this scenario: you have a WCF web service that gets hit up to
I've got a web app that sends a request to a WCF service. The
I have a WCF service that gets called from a client. When there is
I have a REST WCF service that has a method that gets a parameter

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.