BuildTools.GoogleAnalytics.EndTimer C# (CSharp) Method

EndTimer() public method

public EndTimer ( string key ) : void
key string
return void
        public void EndTimer(string key)
        {
            if (timer.ContainsKey(key)) {
                DateTime start = timer[key];

                long time = (long) (DateTime.Now - start).TotalMilliseconds;

                timer.Clear();

                NameValueCollection values = new NameValueCollection() {
                    { "t", "timing" },
                    { "utc", key },
                    { "utv", key },
                    { "utl", key },
                    { "utt", time.ToString() },
                     { "ua", "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT " + Environment.OSVersion.Version.Major + "." + Environment.OSVersion.Version.Minor +  "; Trident/6.0; Touch)" }
                };

                Send(values);
            }
        }

Usage Example

Example #1
0
        // Run BuildTools Button Clicked
        private void runBT_Click(object sender, EventArgs e)
        {
            bool   update = autoUpdateCB.Checked;
            string version;

            if (versionBox.SelectedIndex == 0)
            {
                version = "latest";
            }
            else
            {
                version = _versions[versionBox.SelectedIndex - 1];
            }

            _running = true;

            Thread thread = new Thread(delegate() {
                _googleAnalytics.SendEvent("BuildTools Run", "Version: " + version);
                _googleAnalytics.StartTimer("BuildTools Run Time");
                _runner.RunBuildTools(update, version);
                Enable();
                ProgressHide();
                _googleAnalytics.EndTimer("BuildTools Run Time");
                _running = false;
            });

            Disable();
            thread.Start();
        }