Unger Technologies LLC

GREG UNGER MY FACEBOOK ATHLETE PAGE MY YOUTUBE CHANNEL Follow me on Twitter FOLLOW ME ON TWITTER

Do you know when to use the different WCF Context Modes?


Let's talk about WCF's InstanceContextMode, give a brief overview of the possible values and determine when to use them.

InstanceContextMode is a property on the ServiceBehaviorAttribute class in .NET Framework 4.5. A developer will use the InstanceContextMode property to specify when new service objects are created.

Because the service object is not directly connected to the communicating channel, the lifetime of the service objects is independent of the lifetime of the channel between a client and the service application. The default value, PerSession, instructs the service application to create a new service object when a new communication session is established between a client and the service application. Subsequent calls in the same session are handled by the same object.

There are 3 context modes in WCF:

  1. PerCall
  2. PerSession (Default)
  3. Single

The default value, PerSession, instructs the service application to create a new service object when a new communication session is established between a client and the service application. Subsequent calls in the same session are handled by the same object. PerSession indicates that each service object handles requests from one client channel. A service configured for private sessions cannot typically support more than a few dozen (or perhaps up to a few hundred) outstanding clients due to the cost associated with each such dedicated service instance.

PerCall creates a new InstanceContext object prior to and recycled subsequent to each call. If the channel does not create a session this value behaves as if it were PerCall. After the method call returns, if the object implements IDisposable, then Windows Communication Foundation calls IDisposable.Dispose on it.

Single creates only one InstanceContext object. It is used for all incoming calls and is not recycled subsequent to the calls. If a service object does not exist, one is created. The singleton service is the ultimate shareable service. When a service is configured as a singleton, all clients get connected to the same single well-known instance independently of each other, regardless of which endpoint of the service they connect to. The singleton service lives forever, and is only disposed of once the host shuts down. The singleton is created exactly once when the host is created.

Which instance context mode to use and when

Per session (Default)

• When you want to maintain states between WCF calls.
• When you don't have very many concurrent connections and don't need to scale up.
• When you have light resource references

Per call

• When you want a stateless services
• When your service holds intensive resources like connection and huge memory objects.
• When scalability is a prime requirement.
• When your WCF functions are called in a single threaded model.

Single

• When you want share global data through your WCF service.
• When scalability is not a concern.



55 comments:

  1. Thank you for this detailed article on Web design training. I’m aspiring to do Web design training.

    ReplyDelete
    Replies
    1. I have read your blog its very attractive and impressive. I like it your blog.

      Dot Net Training in Chennai Dot Net Training in Chennai .Net Online Training .Net Online Training Dot Net Training in Chennai Dot Net Training in Chennai


      Dot Net Online Training Dot Net Online Training LINQ Online Training LINQ Online Training ASP.NET Online Training ASP.NET Online Training

      Delete
  2. Thank you for this valuable information. It was really helpful.

    IOSH safety course in Kuwait

    ReplyDelete
  3. This is really an awesome article. Thank you for sharing this.It is worth reading for everyone. Visit us:
    Oracle Training in Chennai

    ReplyDelete
  4. great article!!!!!This is very importent information for us.I like all content and information.I have read it.You know more about this please visit again.
    Oracle RAC Training in Chennai

    ReplyDelete
  5. Wonderful tips, very helpful well explained. Your post is definitely incredible. I will refer this to my friend.
    SalesForce Training in Chennai

    ReplyDelete
  6. I am reading your post from the beginning, it was so interesting to read & I feel thanks to you for posting such a good blog, keep updates regularly.
    Java Training in Chennai

    ReplyDelete
  7. Really awesome blog. Your blog is really useful for me. Thanks for sharing this informative blog. Keep update your blog.
    PHP Training in Chennai

    ReplyDelete
  8. Thanks for sharing this valuable information to our vision. You have posted a trust worthy blog keep sharing.Nice article i was really impressed by seeing this article, it was very interesting and it is very useful for me..
    Android Training in Chennai

    ReplyDelete
  9. Really awesome blog. Your blog is really useful for me. Thanks for sharing this informative blog. Keep update your blog.
    SAP Training in Chennai

    ReplyDelete
  10. Excellent information with unique content and it is very useful to know about the information based on blogs.
    Hadoop Training in Chennai

    ReplyDelete
  11. Excellent information with unique content and it is very useful to know about the information based on blogs.
    Hadoop Training In Chennai | oracle apps financials Training In Chennai | advanced plsql Training In Chennai

    ReplyDelete
  12. Good article with excellent idea! I appreciate your post.Regards Sarkari Result

    ReplyDelete
  13. It’s really a nice and helpful piece of information. I’m glad that you shared this helpful info with us. Please keep us informed like this.
    Employment News in India

    ReplyDelete
  14. Thank you for explaining to us as to when to use this mode. It was really helpful.

    jewelry photo editing services

    ReplyDelete
  15. Interesting blog to know about WCF Modes.Thanks for the blog.Please keep updating us.

    Hadoop training in chennai

    ReplyDelete
  16. I got a good idea when to use WCF and i hope it should be useful all .Net experts. We are providing Dot Net Training in Chennai at IICT. I hope we are giving training in all the concepts you can check our IICT Reviews as well.

    ReplyDelete
  17. This is really a great post. Thank you for taking time to provide us some of the useful and exclusive information with us. Keep on blogging!!

    Salesforce Training in Chennai

    ReplyDelete
  18. These provided information was really so nice,thanks for giving that post and the more skills to develop after refer that post. Your articles really impressed for me,because of all information so nice.

    Selenium training in adyar

    ReplyDelete
  19. I Have Been wondering about this issue, so thanks for posting.
    vigrx plus

    ReplyDelete

  20. I feel happy about and I love learning more about this topic. keep sharing your information regularly for my future reference. This content creates a new hope and inspiration with in me. Thanks for sharing article like this.

    informatica training in Mylapore

    ReplyDelete
  21. Well, I read this information first time in your blog. That was a great research, it really nice and amazing one dear.Contact Us Content

    ReplyDelete
  22. The Information which you provided is very much useful for us. Thank You for Sharing Valuable Information. QTP Training in Chennai | Software Testing Training in Chennai

    ReplyDelete
  23. Everyone loves it when individuals come together and share thoughts. Great blog, continue the good work!
    salesforce training in hyderabad

    ReplyDelete
  24. Useful Information
    one and only affiliate agency in south INDIA, earn money online from affiliate network in india

    ReplyDelete
  25. Awesome Blog.Informative Post.Thanks for sharing the information.
    Incor One City Hyderabad

    ReplyDelete
  26. Well Said, you have furnished the right information that will be useful to anyone at all time. Thanks for sharing your Ideas.
    Hadoop Training in Chennai | Hadoop Training Chennai

    ReplyDelete
  27. Good article with excellent idea! I appreciate your post
    unix training in chennai

    ReplyDelete
  28. Thank you for explaining to us as to when to use this mode. It was really helpful.
    ios training in chennai

    ReplyDelete
  29. The strategy you have posted on this technology helped me to get into the next level and had lot of information in it.
    Dot net training in Chennai | dot net course in Chennai

    ReplyDelete
  30. Its really helpfull.., thanks for sharing this.

    Papa jobs Providing latest information about Current affairs, Bank Recruitment, Government jobs, Bank jobs, IT jobs., check this link papa jobs i hope this is very use full to you and all the very best Guys.

    ReplyDelete
  31. Nice information for job seekers. Thanks for sharing the awesome information , i also recommend online Notification

    ReplyDelete
  32. Wonderful blog.. Thanks for sharing informative blog.. its very useful to me..

    iOS Training in Chennai

    ReplyDelete
  33. watch series At Watch Series Database You Can Watch Series Online for free, The Website Is Updated On Daily Basis With New Tv Shows Episodes.

    ReplyDelete
  34. This comment has been removed by the author.

    ReplyDelete
  35. Judi Bola Online Terbesar dan Terpercaya di Indonesia, Agen Bola Terbaik, Agen Casino Online, Agen Judi Poker Online.
    bandar judi

    ReplyDelete
  36. MICKEY MOUSE Male Extra pills are famous on the market. But you have to know some side effects and results. My prof review will help you.

    ReplyDelete
  37. This comment has been removed by the author.

    ReplyDelete
  38. " Anabolic Steroids Anabolic steroids are synthetic variations of the male sex hormone testosterone Anabolic steroids are synthetic variations of the male sex hormone testosterone They promote the growth of skeletal muscle (anabolic effects) and the development of male sexual characteristics (androgenic effects) in both males and females.
    "

    ReplyDelete
  39. The blog gave me idea to use WCF thanks for sharing it
    Hadoop Training in Chennai

    ReplyDelete
  40. Penomet Penis Pump Review - A detailed and honest review with pictures, personal experiences and product information.
    best penis pumps

    ReplyDelete
  41. Looking to find out if Hair Loss Protocol's natural ingredients can help? ... whether or not there's sufficient clinical evidence showing they can help regrow hair.
    http://fitlivings.com/regrow-hair-protocol-review/

    ReplyDelete

  42. This article is so informatic and it really helped me to know more about the Selenium Testing. So keep updating the content regularly.
    Selenium Training in Chennai | Selenium Training | Selenium Course in Chennai

    ReplyDelete
  43. hi welcome to this blog. really you have post an informative blog. it will be really helpful to many peoples. thank you for sharing this blog.
    android training in chennai

    ReplyDelete
  44. The sharing this way of blog post looks was really amazing. I agree that selenium automation IT right now and it one the best future platform to yours confidence level working style.
    Hadoop Training
    Learn Hadoop Training
    Best Hadoop Training Institute

    ReplyDelete
  45. Nice to be visiting your blog again, it has been months for me. Well this article that i've been waited for so long.

    https://en.gravatar.com/marinemuscle
    https://medium.com/@jamicarpuenter
    http://www.purevolume.com/listeners/Jamipuent

    ReplyDelete
  46. Phen24 is essentially a weight loss solution which works for 24-hours a day! It is known to combine the day and night system and complements your diet

    ReplyDelete
  47. http://www.schnellmuskelnaufbauen.org/

    ReplyDelete
  48. Marine Muscle is all natural american military grade hardcore legal alternative to steroids. No side effects and no prescription are required.

    http://marinemusclepro.com/

    ReplyDelete
  49. Nice one, very impressive and more informative article, thanks for sharing your valuable info and time, it is very easy to learn and understand by me.
    Java Training institute in chennai |Java Training institute in velachery

    ReplyDelete
  50. Nice to read your ideas, thanks for sharing wonderful ideas and article, keep rocks....
    PHP Training in velachery | PHP Training institute in velachery

    ReplyDelete
  51. provides details about v tight gel which helps in getting tighter vaginal walls and improves ...

    ReplyDelete