protected override void OnCustomCommand(int command) { try { CustomCommand?.Invoke(this, new CustomCommandEventArgs(command)); } catch (Exception e) { WriteEntry(ServiceName, string.Format("{0} threw an exception: {1}", ServiceName, e), EventLogEntryType.Error); } }