protected override async Task HandleMessage(PiCalcMessage msg) { Console.WriteLine($"Started processing task {msg.Id}, " + $"task name: {msg.Name}, " + $"precision: {msg.Precision}..."); subscriptionHandler.Register(msg.Id); var result = piCalcService.Calculate( msg.Precision, () => subscriptionHandler.IsStopped(msg.Id)); var publisher = new MessagePublisher <PiCalcResultMessage>(busClient); await publisher.Publish( new PiCalcResultMessage { Id = msg.Id, Pi = result.ToString() }); Console.WriteLine($"Calculated PI (task Id: {msg.Id}, " + $"task name: {msg.Name}, " + $"precision: {msg.Precision}) : " + $"{result.ToString()}"); }
private static void LoadInternal(ISubscriptionHandler ish, string installPath, string settingsPath) { string name = null; try { if (ish != null) { name = ish.Name; loadedHandlersList.Add(ish); List <Type> list = ish.Register(); foreach (Type type in list) { if (typeof(Subscription).IsAssignableFrom(type)) { if (!loadedTypes.ContainsKey(type)) { lock (loadedTypes) { if (!loadedTypes.ContainsKey(type)) { loadedTypes.Add(type, ish); } } } } } Utility.WriteDebugInfo(String.Format("Subscriber '{0}' was loaded successfully", name)); } } catch (Exception ex) { // suppress any per-plugin loading exceptions Utility.WriteDebugInfo(String.Format("Subscriber failed to load: '{0}' - {1} - {2}", name, ex.Message, ex.StackTrace)); } }
private static void LoadInternal(ISubscriptionHandler ish, string installPath, string settingsPath) { string name = null; try { if (ish != null) { name = ish.Name; loadedHandlersList.Add(ish); List<Type> list = ish.Register(); foreach (Type type in list) { if (typeof(Subscription).IsAssignableFrom(type)) { if (!loadedTypes.ContainsKey(type)) { lock (loadedTypes) { if (!loadedTypes.ContainsKey(type)) { loadedTypes.Add(type, ish); } } } } } Utility.WriteDebugInfo(String.Format("Subscriber '{0}' was loaded successfully", name)); } } catch (Exception ex) { // suppress any per-plugin loading exceptions Utility.WriteDebugInfo(String.Format("Subscriber failed to load: '{0}' - {1} - {2}", name, ex.Message, ex.StackTrace)); } }