WCF/Silverlight: Why use a ChannelFactory instead of a Client?

喜夏-厌秋 提交于 2019-12-22 17:39:13

问题


In inherited a project that uses a ChannelFactory instead of a Client for WCF calls. Why would you do that?

Also, is it safe to cache the result of a ChannelFactory.CreateChannel() call or should you create a new one each time?


回答1:


Creating the WCF client is a two-step process:

  • creating the channel factory
  • using that channel factory, create the actual channel

Step 1 is rather expensive in terms of processing power and speed - so if you can create the channel factory and then cache is somewhere, you can save yourself a bit of resources and create a channel off that cached channel factory will be faster than re-creating the whole client all the time.

So in this setup, I would try to cache the ChannelFactory, if you can - and re-create the channel from that factory every time you need it.



来源:https://stackoverflow.com/questions/4888880/wcf-silverlight-why-use-a-channelfactory-instead-of-a-client

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!