private async void NpsmServiceStart_NpsmServiceStarted(object sender, EventArgs e)
        {
            //Example: explorer.exe crashes, the NPSMLib still holds the "link"
            //THEN explorer.exe restarts and NPSM restarts too, reloading all NPSM sessions

            //Now recreate NPSessionManager.
            try
            {
                NPSessionManager = new();
                NPSessionManager.SessionListChanged += NPSessionsChanged;

                await LoadSessions();
            }
            catch (Exception)
            {
                //This is in case NPSM dies immediately after sending a wnf notification
                await ClearSessions();

                if (NPSessionManager != null)
                {
                    NPSessionManager.SessionListChanged -= NPSessionsChanged;
                }
                NPSessionManager = null;
            }
        }
        public override void OnDisabled()
        {
            if (NPSessionManager != null)
            {
                NPSessionManager.SessionListChanged -= NPSessionsChanged;
                NPSessionManager = null;
            }

            ClearSessions();
        }
Exemple #3
0
        private async Task CleanupNPSM()
        {
            if (NPSessionManager != null)
            {
                NPSessionManager.SessionListChanged -= NPSessionsChanged;
                NPSessionManager = null;
            }

            await ClearSessions();
        }
        public override void OnEnabled()
        {
            try
            {
                NPSessionManager = new();
                NPSessionManager.SessionListChanged += NPSessionsChanged;
                LoadSessions();

                NpsmServiceStart.NpsmServiceStarted += NpsmServiceStart_NpsmServiceStarted;
            }
            catch (System.Exception)
            {
                //The NPSM service may NOT be available.
                NpsmServiceStart.NpsmServiceStarted += NpsmServiceStart_NpsmServiceStarted;
            }
        }
        private void NpsmServiceStart_NpsmServiceStarted(object sender, System.EventArgs e)
        {
            //For some reasons it doesn't clear the sessions (you'll have duplicates)...
            //But at least it shouldn't die anymore
            //Oh, and of course this fixes 19041 issue where GSMTC/NPSMLib stops working randomly...
            //Well, the NPSM service crashes and restarts but old handles still remains.
            //That's why we create a new instance when NPSM is (re)started so we have a new one.

            Application.Current.Dispatcher.Invoke(() =>
            {
                try
                {
                    NPSessionManager = new();
                    NPSessionManager.SessionListChanged += NPSessionsChanged;

                    LoadSessions();
                }
                catch (System.Exception)
                {
                    //This is in case NPSM dies immediately after sending a wnf notification
                }
            });
        }
Exemple #6
0
        private async Task OnNpsmServiceStarted()
        {
            //Example: explorer.exe crashes, the NPSMLib still holds the "link"
            //THEN explorer.exe restarts and NPSM restarts too, reloading all NPSM sessions

            //Now recreate NPSessionManager.

            try
            {
                await CleanupNPSM();

                NPSessionManager = new();
                NPSessionManager.SessionListChanged += NPSessionsChanged;

                await LoadSessions();
            }
            catch
            {
                //This is in case NPSM dies immediately after sending a wnf notification

                await CleanupNPSM();
            }
        }