简体   繁体   English

WCF - GetCallbackChannel 可靠吗?

[英]WCF - Is GetCallbackChannel reliable?

In the part " Figure 5 Storing the Callback References for Later Use " of this tutorial , it's clear that the service would need to keep the manual cache list synchronized reflecting the connected clients only to prevent exceptions caused by the reference to old clients that got disconnected.本教程的图 5 存储回调引用以备后用”部分中,很明显,该服务需要保持手动缓存列表同步以反映连接的客户端,只是为了防止因引用断开连接的旧客户端而导致异常. But, if I don't plan to use such a cache mechanism (for which I don't see any need at all) and I directly access GetCallbackChannel<T> instead to perform event calls to the client, is it guaranteed that the internal list will only contain all connected clients and would never throw a corresponding CommunicationException when calling a contained event?但是,如果我不打算使用这样的缓存机制(我认为根本不需要)并且我直接访问GetCallbackChannel<T>而不是执行对客户端的事件调用,是否可以保证内部list 将只包含所有连接的客户端,并且在调用包含的事件时永远不会抛出相应的CommunicationException

Sorry, I hadn't read here where it says:对不起,我没有这里读到它说:

Gets a channel to the client instance that called the current operation.获取调用当前操作的客户端实例的通道。

This immediately causes the " Figure 5 Storing the Callback References for Later Use " part of the first tutorial to make sense now, as we'll call the clients (supporting multiple in fact) in another thread (so deferred to their requests).这立即导致第一个教程的“图 5 存储回调引用以供以后使用”部分现在变得有意义,因为我们将在另一个线程中调用客户端(实际上支持多个)(因此推迟到他们的请求)。 I thought GetCallbackChannel simply represented the whole acknowledged callbacks (one per client) at any point of the service execution.我认为GetCallbackChannel只是在服务执行的任何一点表示整个已确认的回调(每个客户端一个)。

I understand then I'll naturally have to catch exceptions such as CommunicationException once I mimic that caching list approach (or simply Exception only).我明白,一旦我模仿了缓存列表方法(或者只是Exception而已),我自然就必须捕获诸如CommunicationException Exception

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM