Single WCF channel performance vs multiple channels

后端 未结 2 1223
情书的邮戳
情书的邮戳 2021-02-08 13:21

I have an application that reuses the same WCF channel over and over again. I keep a static reference through a factory object. I wonder if this is good pratice or that I should

2条回答
  •  逝去的感伤
    2021-02-08 13:39

    @Darin Dimitrov

    Reuse the same proxy In many cases, you would want to reuse the same proxy. This has the best performance. It is especially true when you use security features since the initial security negotiation can have high cost.

    proxy equals channel. if you look at this blog post, you can see the following code snippet:

    ISimpleContract proxy = factory.CreateChannel();
    ((IClientChannel)proxy).Open();
    

    Furthermore, if you plan to work with sessions, you don't want to establish a new session for each request (by creating a new channel/proxy each time).

提交回复
热议问题