Sign In
Nicholas Allen's Indigo Blog
Windows Communication Foundation From the Inside
Translate This Page
Translate this page
Powered by
Microsoft® Translator
Options
Blog Home
About
Email Blog Author
Share this
RSS for posts
Atom
RSS for comments
Search
Advanced search options...
Search In:
Everything
Blogs
Forums
People
Groups
Places
Pages
Date range:
All Time
Last Year
Last 6 Months
Last 3 Months
Last Month
Last Week
Last Two Days
Tags
Answers
Bindings
Channel Extensibility
Channels
Conferences
Contracts
Debugging
Hosting
HTTP
Indigo
Learning
Message Security
Messages
Net4
Networking
Orcas
Proxies
Releases
Security
Service Architecture
Service Model
Silverlight
TCP/IP
Transport Security
Transports
Archive
Archives
June 2010
(1)
May 2010
(9)
April 2010
(22)
March 2010
(23)
February 2010
(20)
January 2010
(20)
December 2009
(21)
November 2009
(21)
October 2009
(22)
September 2009
(22)
August 2009
(22)
July 2009
(22)
June 2009
(22)
May 2009
(20)
April 2009
(22)
March 2009
(22)
February 2009
(20)
January 2009
(21)
December 2008
(21)
November 2008
(18)
October 2008
(23)
September 2008
(21)
August 2008
(21)
July 2008
(22)
June 2008
(22)
May 2008
(21)
April 2008
(22)
March 2008
(21)
February 2008
(21)
January 2008
(22)
December 2007
(19)
November 2007
(20)
October 2007
(23)
September 2007
(19)
August 2007
(23)
July 2007
(21)
June 2007
(21)
May 2007
(22)
April 2007
(22)
March 2007
(22)
February 2007
(20)
January 2007
(23)
December 2006
(20)
November 2006
(23)
October 2006
(24)
September 2006
(24)
August 2006
(23)
July 2006
(21)
June 2006
(26)
May 2006
(23)
April 2006
(20)
March 2006
(26)
February 2006
(20)
Five Pitfalls of the Channel Model, Part 1
MSDN Blogs
>
Nicholas Allen's Indigo Blog
>
Five Pitfalls of the Channel Model, Part 1
Five Pitfalls of the Channel Model, Part 1
Nicholas Allen
3 Apr 2006 8:00 AM
Comments
1
Although the WCF channel model has a relatively simple set of APIs, it has a very subtle set of rules for using those APIs. I've picked out a small collection of rules to talk about for the next two posts. You might have seen some of these before if you're a regular reader, but everything here is worth saying at least twice. I may run follow-ups in the future to collect more rules as we come across them. There is no shortage of wrong ways to use the channel model.
Pitfall #1:
There's always a limit, even if no one tells you what it is
This is the best pitfall to employ when you need a mysteriously bad experience at random intervals. Every operation has some threshold for timeliness, above which you'll start incurring user unhappiness. Sometimes you know what that threshold is, although frequently you'll just have to guess. The timeout model in WCF is that the threshold you set for an operation bubbles down to its suboperations so that they know how much time is remaining. For various reasons, not every method allows you to specify a timeout. That doesn't mean you have an unlimited amount of time. Since you don't know how much time you can afford to spend, that means you must never take an appreciable amount of time to complete an operation without a timeout.
Pitfall #2: Clean up your toys when you're done
Most of the channel model has an explicit cleanup arrangement through the Close method. An IDisposable implementation is often provided as a synonym for Close so that you can take advantage of the using syntax in C# to define a containment block. It is a bad idea to not close an object after you're done. At the level of the channel model, we don't promise to clean up after you. Failing to call Close can lead to leaks of both memory and network resources, such as ports, namespaces, and available connections, for significant periods of time. Don't let this happen to you.
Pitfall #3:
If you break a message, you've bought it
A message is one of those objects that have an explicit cleanup requirement. The difference between messages and things like channels is that messages are far more likely to be passed around. There is one, and only one, owner for each message. When a message is passed through a function, there should be some indication of whether ownership of the message has also been handed off. Typically, giving away a message is equivalent to giving away its ownership. The person that received the message will then either pass the message on to someone else or break the message open to read its contents. Once you break open a message, you're pretty much stuck cleaning it up because you can't pass it on.
Next time:
Five Pitfalls of the Channel Model, Part 2
1 Comments
Channels
,
Indigo
Blog - Comment List MSDN TechNet
Comments
Loading...