DroidExplorer.Core.UI.TransferDialog.SpeedTest C# (CSharp) Method

SpeedTest() private method

private SpeedTest ( ) : void
return void
        private void SpeedTest( )
        {
            SetTimeStatus ( "Calculating..." );
            try {
                if ( kbs <= 0 ) {
                    string path = System.IO.Path.GetDirectoryName ( this.GetType ( ).Assembly.Location );
                    DroidExplorer.Core.TransferCommandResult tcr = CommandRunner.Instance.PushFile ( System.IO.Path.Combine ( path, @"Data\speedtest.png" ), "/sdcard/speedtest.png" ) as DroidExplorer.Core.TransferCommandResult;
                    kbs = tcr.KillobytesPerSecond;
                    CommandRunner.Instance.DeleteFile ( "/sdcard/speedtest.png" );
                }

                int secs = 0;
                string s = ( ( this.TotalSize / 1024 ) / kbs ).ToString ( );
                int.TryParse ( s, out secs );
                TimeSpan ts = new TimeSpan ( 0, 0, secs );
                SetTimeStatus ( ts.ToString ( ) );
                timeRemainingTimer = new System.Threading.Timer ( delegate ( object o ) {
                    try {
                        if ( ts.TotalSeconds > 0 ) {
                            ts = ts.Subtract ( new TimeSpan ( 0, 0, 1 ) );
                            if ( this.InvokeRequired ) {
                                this.Invoke ( new SetLabelStatusDelegate ( this.SetTimeStatus ), new object[] { ts.ToString ( ) } );
                            } else {
                                SetTimeStatus ( ts.ToString ( ) );
                            }
                        } else {
                            timeRemainingTimer = null;
                        }
                    } catch ( Exception ex ) {
                        this.LogError ( ex.Message, ex );
                    }
                }, null, new TimeSpan ( 0, 0, 1 ), new TimeSpan ( 0, 0, 1 ) );
            } catch ( Exception ex ) {
                SetTimeStatus ( "Unknown" );
                this.LogError ( ex.Message, ex );
            }
        }