/// <summary> /// Receives incoming notifications and informs any subscribers. /// </summary> private void NotificationProcessingThread() { while (!_isDisposed) { Thread.Sleep(1); // only bother if it's been fully converted, otherwise it will gobble up the initial status response if (NotificationSession == null || !NotificationSession.Options.HasFlag(XboxConnectionOptions.NotificationSession)) { continue; } // look for a new notification string notification = NotificationSession?.TryReceiveLine(); if (notification == null) { continue; } // save for later Logger?.Debug($"Notification received: {notification}"); NotificationHistory.Enqueue(notification); // start dequeuing old entries if greater than max history count if (NotificationHistory.Count > MaxNotificationHistoryCount) { string garbage; NotificationHistory.TryDequeue(out garbage); } // inform any subscribers NotificationReceived?.Invoke(this, new XboxNotificationEventArgs(notification)); } }
/// <summary> /// Disconnects from the Xbox. /// </summary> public void Disconnect() { Memory?.Dispose(); Memory = null; Kernel = null; System = null; Process = null; DebugMonitor = null; FileSystem = null; ConnectionId = 0; CommandSession?.Dispose(); CommandSession = null; NotificationSession?.Dispose(); NotificationSession = null; }