Exemple #1
0
        private void GetTrafficInformation()
        {
            // use Task to get the information in background
            Task.Factory.StartNew(() =>
            {
                // set the loop to update the value
                while (true)
                {
                    //divisionParameter = 1.0;
                    if (loadedInterfaceIndex > -1)
                    {
                        // get the control of the object
                        this.Dispatcher.Invoke(() => {
                            // get data from common data
                            commonSet.GetTrafficInformation(loadedSpeedUnitIndex,
                                                            loadedInterfaceIndex);


                            if (!needResetTraffic)
                            {
                                // update the traffic value of the object
                                this.UploadTrafficTextBlock.Text = String.Format("{0:F2} "
                                                                                 + loadedSpeedUnit, commonSet.uploadTrafficValue);

                                this.DownloadTrafficTextBlock.Text = String.Format("{0:F2} "
                                                                                   + loadedSpeedUnit, commonSet.downloadTrafficValue);
                            }
                            else
                            {
                                needResetTraffic = false;
                            }

                            /*
                             * // update the current value as previous value
                             * previousUploadValue = uploadTrafficValueTemp;
                             * previousDownloadValue = downloadTrafficValueTemp;*/
                        });
                    }
                    Thread.Sleep(Convert.ToInt32(loadedUpdateFrequency * 1000));
                }
            });
        }
Exemple #2
0
        private void GetTrafficInformation()
        {
            // use Task to get the information in background
            Task.Factory.StartNew(() =>
            {
                // set the loop to update the value
                while (true)
                {
                    //divisionParameter = 1.0;
                    if (selectedInterfaceIndex > -1)
                    {
                        // get the control of the object
                        this.Dispatcher.Invoke(() => {
                            // get data from common data
                            commonSet.GetTrafficInformation(this.SpeedUnitSelectionBox.SelectedIndex,
                                                            this.NetworkInterfaceSelectionBox.SelectedIndex);



                            if (!needResetTraffic)
                            {
                                // update the traffic value of the object
                                this.UploadTrafficTextBlock.Text = String.Format("{0:F2} "
                                                                                 + this.SpeedUnitSelectionBox.Text, commonSet.uploadTrafficValue);

                                this.DownloadTrafficTextBlock.Text = String.Format("{0:F2} "
                                                                                   + this.SpeedUnitSelectionBox.Text, commonSet.downloadTrafficValue);
                            }
                            else
                            {
                                needResetTraffic = false;
                            }
                        });
                    }
                    Thread.Sleep(Convert.ToInt32(updateFrequency * 1000));
                }
            });
        }