예제 #1
0
        async Task UpdateProcessesCollectionPeriodicallyAsync(int interval
                                                              )
        {
            while (true)
            {
                await Task.Delay(TimeSpan.FromSeconds(interval));

                Debug.Assert(mainWindowViewModel != null);
                Debug.Assert(mainWindowViewModel.Processes != null);

                IEnumerable <Process> processes = ProcessFetcher.FetchProcesses();

                synchronizationContext.Post(_ =>
                {
                }, 1);
            }
        }
예제 #2
0
        public void StartRefreshing(int collectionRefreshInterval, int processDataRefreshInterval)

        {
            if (collectionRefreshInterval < 0 || processDataRefreshInterval < 0)
            {
                throw new ArgumentException("Interval must be > 0 ");
            }

            if (mainWindowViewModel.Processes == null)
            {
                throw new ArgumentNullException(nameof(mainWindowViewModel.Processes));
            }

            ProcessesUpdater.UpdateProcessCollection(ProcessFetcher.FetchProcesses(), mainWindowViewModel.Processes);

            Task.Run(() =>
            {
                UpdateProcessesCollectionPeriodicallyAsync(collectionRefreshInterval
                                                           ).Wait();
            });
        }