Exemplo n.º 1
0
        public void SuspendTabs(bool freeze = true)
        {
            var affectedPids = new List <int> ( );

            foreach (var pid in Pids)
            {
                try
                {
                    if (!TryGetProcess(pid, out var process))
                    {
                        continue;
                    }

                    affectedPids.Add(pid);
                    if (freeze)
                    {
                        process.Suspend( );
                    }
                    else
                    {
                        process.Resume( );
                    }
                }
                catch (Exception e)
                {
                    _errorSubject.OnNext(new FreezeError(pid, exception: e));
                }
            }


            SetTabsState(freeze
                                                           ? ChromeTabsState.Suspended(affectedPids)
                                                           : ChromeTabsState.Resumed(affectedPids));
        }
Exemplo n.º 2
0
        public ChromeMonitor(FreezerSettings settings)
        {
            Settings  = settings;
            Pids      = ImmutableList <int> .Empty;
            TabsState = ChromeTabsState.Resumed(Enumerable.Empty <int> ( ));
            State     = ChromeMonitorState.Stopped;

            _extractor = new ChromeTabsPidExtractor( );
        }