ServiceBehavior(InstanceContextMode = InstanceContextMode.PerSession)] public class NotificationService : INotificationService { static Action<string> sendDataEvent = delegate { }; private INotificationServiceCallBack GetCurrentCallback() { return OperationContext.Current.GetCallbackChannel<INotificationServiceCallBack>(); } public void Subscribe() { var subscriber = GetCurrentCallback(); sendDataEvent += subscriber.SendResult; } public void Execute() { //logic and then send the result back sendDataEvent(measurements); } }
public class TestDataInterface:INotificationServiceCallback,INotifyPropertyChanged { static Dictionary<string, TestDataInterface> instance=null; string testBench=string.Empty; NotificationService.NotificationServiceClient notificationProxy; private TestDataInterface(string testBenchName) { testBench = testBenchName; notificationProxy = new NotificationService.NotificationServiceClient(new InstanceContext(this)); notificationProxy.Subscribe(); } public static TestDataInterface Instance(string testBenchName) { if (instance == null) instance = new Dictionary<string, TestDataInterface>(); //Add object only if key testBenchName is not found if (!instance.ContainsKey(testBenchName)) { instance.Add(testBenchName, new TestDataInterface(testBenchName)); } return instance[testBenchName]; } #region INotificationServiceCallback Methods public void SendResult(string testResult) { //logic } #endregion public void ExecuteCommand(string command) { notificationProxy.Execute(command); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)