예제 #1
0
        private void ExecThread()
        {
            Thread.Sleep(WARMUP_DELAY_MS);

            while (true)
            {
                try
                {
                    StabilityCookie.WriteUptimeBeat(DateTime.Now.Subtract(startTime));

                    //Disable heartbeat to avoid 150 event/session limit
                    //InstrumentationLogger.LogAnonymousEvent("Heartbeat", "ApplicationLifeCycle", GetVersionString());

                    String usage  = PackFrequencyDict(ComputeNodeFrequencies());
                    String errors = PackFrequencyDict(ComputeErrorFrequencies());

                    Analytics.LogPiiInfo("Node-usage", usage);
                    Analytics.LogPiiInfo("Nodes-with-errors", errors);

                    DynamoModel.OnRequestDispatcherInvoke(
                        () =>
                    {
                        string workspace = dynamoModel.CurrentWorkspace == null ? string.Empty :
                                           dynamoModel.CurrentWorkspace
                                           .GetStringRepOfWorkspace();
                        Analytics.LogPiiInfo("Workspace", workspace);
                    });
                }
                catch (Exception e)
                {
                    Debug.WriteLine("Exception in Heartbeat " + e);
                }

                // The following call will return "true" if the event is
                // signaled, which can only happen when "DestroyInternal"
                // is called as the application is shutting down. Otherwise,
                // when the wait time ellapsed, the loop continues to log
                // the next set of information.
                //
                if (shutdownEvent.WaitOne(HEARTBEAT_INTERVAL_MS))
                {
                    break;
                }
            }
        }