我有一个Duplex服务(Singleton),曾经使用WSDualHttpBinding,并且在将其更改为双工CustomBinding以支持BinaryEncoding时出于性能原因,它停止工作。对于所有客户端请求,GetCallBackChannel的问题跟踪总是返回相同的HashCode(在该服务实例内),并且List认为它已经存在于订阅的通道中并且不会添加到订阅者列表。我正在使用C#3.5
请提出解决方案..
提前致谢...
public void Subscribe(string topicName)
{
try
{
Notifier.IPublishing subscriber = OperationContext.Current.GetCallbackChannel<IPublishing>();
Notifications.Filter.AddSubscriber(topicName, subscriber);
}
catch (Exception ex)
{
ErrorLog.WriteToLog("Subscribe\n" + ex.ToString());
}
}
static public void AddSubscriber(String topicName, IPublishing subscriberCallbackReference)
{
lock (typeof(Filter))
{
if (SubscribersList.ContainsKey(topicName))
{
if (!SubscribersList[topicName].Contains(subscriberCallbackReference))
{
SubscribersList[topicName].Add(subscriberCallbackReference);
}
}
else
{
List<IPublishing> newSubscribersList = new List<IPublishing>();
newSubscribersList.Add(subscriberCallbackReference);
SubscribersList.Add(topicName, newSubscribersList);
}
}
}
答案 0 :(得分:1)