我在wcf服务中使用wsDualHttpBinding,并使用以下代码存储客户端通道:
public static void Subscribe()
{
try
{
// Subscribe the guest to the beer inventory
var guest = OperationContext.Current.GetCallbackChannel<ILoggingServiceCallBack>();
if (!CallbackList.Contains(guest))
{
CallbackList.Add(guest);
}
}
catch (Exception ex)
{
//do stuff
}
finally
{
//do stuff
}
}
我打电话给那样的客户:
public static void LoggingCallBack(Action<ILoggingServiceCallBack> callbackNotification)
{
try
{
if (OperationContext.Current != null)
{
var guest = OperationContext.Current.GetCallbackChannel<ILoggingServiceCallBack>();
if (!CallbackList.Contains(guest))
{
CallbackList.Add(guest);
}
}
foreach (var LoggingCallBack in CallbackList)
{
var temp = LoggingCallBack;
try
{
new Thread(() =>
{
try
{
callbackNotification(temp);
}
catch (Exception ex)
{
//do something
}
}).Start();
}
catch (Exception ex)
{
//do somethin
}
}
}
catch (Exception ex)
{
//doing something
}
finally
{
//doing something
}
}
我遇到了一些麻烦:
对不起,如果我提出了多个问题,请就我发布的代码以及上述问题的任何答案发表意见。