Example #1
0
        private void DestroyInternal()
        {
            //Are we shutting down clean if so write 'nice shutdown' cookie
            if (DynamoModel.IsCrashing)
            {
                StabilityCookie.WriteCrashingShutdown();
            }
            else
            {
                StabilityCookie.WriteCleanShutdown();
            }

            System.Diagnostics.Debug.WriteLine("Heartbeat Destory Internal called");

            shutdownEvent.Set(); // Signal the shutdown event...

            // TODO: Temporary comment out this Join statement. It currently
            // causes Dynamo to go into a deadlock when it is shutdown for the
            // second time on Revit (that's when the HeartbeatThread is trying
            // to call 'GetStringRepOfWorkspaceSync' below (the method has no
            // chance of executing, and therefore, will never return due to the
            // main thread being held up here waiting for the heartbeat thread
            // to end).
            //
            // heartbeatThread.Join(); // ... wait for thread to end.

            heartbeatThread = null;
        }
Example #2
0
        private Heartbeat(DynamoModel dynamoModel)
        {
            // KILLDYNSETTINGS - this is provisional - but we need to enforce that Hearbeat is
            // not referencing multiple DynamoModels
            this.dynamoModel = dynamoModel;

            StabilityCookie.Startup();

            startTime       = DateTime.Now;
            heartbeatThread = new Thread(this.ExecThread);
            heartbeatThread.IsBackground = true;
            heartbeatThread.Start();
        }
Example #3
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());

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

                    dynamoModel.OnRequestDispatcherInvoke(
                        () =>
                    {
                        string workspace =
                            dynamoModel.CurrentWorkspace
                            .GetStringRepOfWorkspace();
                        InstrumentationLogger.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;
                }
            }
        }