///unclear how to make this safe public SafeThread(ThreadStart start, string name, HomeOS.Hub.Platform.Views.VLogger logger) { this.logger = logger; thread = new Thread(delegate() { try { start(); } catch (Exception exception) { //string message = "HomeOS SafeThread named: " + name + ", raised exception: " + exception.GetType(); string message = "HomeOS SafeThread named: " + name + ", raised exception: " + exception.ToString(); if (logger != null) { logger.Log(message); } //lets print these messages to stderr as well Console.Error.WriteLine(message); } } ); thread.Name = name; }
/// <summary> /// Constructor for the Port object /// </summary> /// <param name="info">The PortInfo object that this port corresponds to</param> /// <param name="owner">The owning module that is initializing the port</param> /// <param name="status">The status of the port (mostly unused right now)</param> /// <param name="logger">The default logging object for log messages from this port</param> /// <param name="handler">The function to call when notifications are received by the port</param> public Port(HomeOS.Hub.Platform.Views.VPortInfo info, HomeOS.Hub.Platform.Views.VModule owner, PortStatus status, HomeOS.Hub.Platform.Views.VLogger logger, OperationReturnHandler handler) { this.portInfo = info; this.Status = status; this.logger = logger; this.handler = handler; this.subscribedPorts = new Dictionary <OperationKey, List <SubscriptionInfo> >(); this.operationDelegates = new Dictionary <OperationKey, OperationDelegate>(); foreach (HomeOS.Hub.Platform.Views.VRole role in info.GetRoles()) { foreach (HomeOS.Hub.Platform.Views.VOperation operation in role.GetOperations()) { this.operationDelegates[new OperationKey(operation.Name())] = null; } } currentCapabilities = new Dictionary <HomeOS.Hub.Platform.Views.VCapability, bool>(); }
///unclear how to make this safe public SafeThread(ThreadStart start, string name, HomeOS.Hub.Platform.Views.VLogger logger) { this.logger = logger; thread = new Thread(delegate() { try { start(); } catch (Exception exception) { //string message = "HomeOS SafeThread named: " + name + ", raised exception: " + exception.GetType(); string message = "HomeOS SafeThread named: " + name + ", raised exception: " + exception.ToString(); logger.Log(message); //lets print these messages to stderr as well Console.Error.WriteLine(message); } } ); thread.Name = name; }