Ejemplo n.º 1
0
        private void OnHostLoadChanged(HostLoad hostLoad)
        {
            Interlocked.Exchange(ref _hostLoad, hostLoad);

            IsConnected = hostLoad != null;
            var args = new HostLoadChangedEventArgs(hostLoad ?? new HostLoad());

            Task.Run(() => HostLoadChanged?.Invoke(this, args)).DoNotWait();
        }
        public void Update()
        {
            var viewModel = new HostLoadIndicatorViewModel(_sessionProvider, _coreShell);
            var eventArgs = new HostLoadChangedEventArgs(_hostLoad);

            _sessionProvider.HostLoadChanged += Raise.Event <EventHandler <HostLoadChangedEventArgs> >(_sessionProvider, eventArgs);

            viewModel.CpuLoad.Should().Be(30);
            viewModel.MemoryLoad.Should().Be(40);
            viewModel.NetworkLoad.Should().Be(50);
            viewModel.Tooltip.Should().Contain("30").And.Contain("40").And.Contain("50");
        }
Ejemplo n.º 3
0
        private void OnHostLoadChanged(object sender, HostLoadChangedEventArgs e)
        {
            _mainThread.Post(() => {
                CpuLoad     = e.HostLoad.CpuLoad;
                MemoryLoad  = e.HostLoad.MemoryLoad;
                NetworkLoad = e.HostLoad.NetworkLoad;

                Tooltip = string.Format(CultureInfo.InvariantCulture,
                                        Resources.HostLoad_Tooltip,
                                        (int)Math.Round(100 * CpuLoad),
                                        (int)Math.Round(100 * MemoryLoad),
                                        (int)Math.Round(100 * NetworkLoad));
            });
        }
        public async Task Update()
        {
            var viewModel = new HostLoadIndicatorViewModel(_sessionProvider, _services.MainThread());
            var eventArgs = new HostLoadChangedEventArgs(_hostLoad);

            _sessionProvider.HostLoadChanged += Raise.Event <EventHandler <HostLoadChangedEventArgs> >(_sessionProvider, eventArgs);

            await UIThreadHelper.Instance.DoEventsAsync(); // Event is dispatched to main thread

            viewModel.CpuLoad.Should().Be(30);
            viewModel.MemoryLoad.Should().Be(40);
            viewModel.NetworkLoad.Should().Be(50);
            viewModel.Tooltip.Should().Contain("30").And.Contain("40").And.Contain("50");
        }
Ejemplo n.º 5
0
        private void OnHostLoadChanged(HostLoad hostLoad) {
            Interlocked.Exchange(ref _hostLoad, hostLoad);

            IsConnected = hostLoad != null;
            var args = new HostLoadChangedEventArgs(hostLoad ?? new HostLoad());
            Task.Run(() => HostLoadChanged?.Invoke(this, args)).DoNotWait();
        }