Reputation: 3451
I am creating channel everytime before performing an operation on service using ChannelFactory.CreateChannel(). At the end of the operation I will close the channel or abort it if there are any exceptions.
Since I am creating a channel each time, do I have to listen to "Faulted" events.
Btw, why channelFactory has Faulted event, when all the stuff is done by the channel.
Or - will be it raised when any of the channels created by this factory faulted?
Thanks in advance, Dreamer!
Upvotes: 1
Views: 1228
Reputation: 28530
The only reason I would listen to the Faulted event is if I wanted to do something particular if the event occurs (other than aborting the channel). I can't, off the top of my head, think of a reason to use it - but that doesn't mean there isn't one.
In your case, if you're aborting the channel when an error occurs, then you're fine - you don't ned to handle the Faulted event.
FactoryChannel<T>
implements ICommunicationObject, which defines a faulted event. MSDN says "Defines the contract for the basic state machine for all communication-oriented objects in the system, including channels, the channel managers, factories, listeners, and dispatchers, and service hosts."
FactoryChannel<T>.CreateChannel
returns a type of IChannel, which also implements ICommunicationObject.
Upvotes: 2