protected override void InnerRun()
            {
                int counter       = 0;
                int totalProjects = widget.projects.Count;

                try {
                    foreach (ProjectProperties projectprop in widget.projects)
                    {
                        CodeMetricsService.AddTypes(projectprop, widget.ctx);
                    }

                    foreach (ProjectProperties projectprop in widget.projects)
                    {
                        ObjectOrientedMetrics.EvaluateOOMetrics(widget.ctx, projectprop);
                        ComplexityMetrics.EvaluateComplexityMetrics(widget.ctx, projectprop);
                        CodeMetricsService.ProcessInnerTypes(projectprop);

                        Gtk.Application.Invoke(delegate {
                            FillTree(projectprop);
                        });
                        if (base.IsStopping)
                        {
                            return;
                        }
                        lock (lockCounter)
                        {
                            counter++;
                            DispatchService.GuiSyncDispatch(delegate {
                                IdeApp.Workbench.StatusBar.SetProgressFraction(counter / (double)totalProjects);
                            });
                        }
                    }
                } catch (Exception e) {
                    Console.WriteLine("Error : " + e.ToString());
                    base.Stop();
                }


                Gtk.Application.Invoke(delegate {
                    IdeApp.Workbench.StatusBar.ShowMessage("Finished calculating metrics\n");
                    IdeApp.Workbench.StatusBar.EndProgress();
                    widget.textviewReport.Buffer.Text  = GettextCatalog.GetString("Finished calculating metrics\n");
                    widget.textviewReport.Buffer.Text += CodeMetricsService.GenerateAssemblyMetricText();
                });

                base.Stop();
            }
        public CodeMetricsWidget()
        {
            this.Build();
            treeviewMetrics.RulesHint = true;
            treeviewMetrics.Model     = metricStore;

            projects = new List <ProjectProperties>();

            crt           = new CellRendererText();
            crt.Ellipsize = Pango.EllipsizeMode.Start;

            iconCol = new TreeViewColumn(GettextCatalog.GetString("Icon"), new Gtk.CellRendererPixbuf(), "pixbuf", 0);
            iconCol.SortIndicator = true;
            iconCol.SortColumnId  = 1;
            iconCol.Expand        = false;
            iconCol.Resizable     = true;
            treeviewMetrics.AppendColumn(iconCol);

            typenameCol = new TreeViewColumn(GettextCatalog.GetString("Type name"), crt, "text", 1);
            typenameCol.SortIndicator = true;
            typenameCol.SortColumnId  = 0;
            typenameCol.Expand        = true;
            typenameCol.Resizable     = true;
            treeviewMetrics.AppendColumn(typenameCol);

            cyclometricComplexityCol = new TreeViewColumn(GettextCatalog.GetString("Cyclometric Complexity"), new CellRendererText(), "text", 2);
            cyclometricComplexityCol.SortIndicator = true;
            cyclometricComplexityCol.SortColumnId  = 0;
            cyclometricComplexityCol.Reorderable   = true;
            cyclometricComplexityCol.Resizable     = false;
            treeviewMetrics.AppendColumn(cyclometricComplexityCol);

            classCouplingCol = new TreeViewColumn(GettextCatalog.GetString("Class Coupling"), new CellRendererText(), "text", 3);
            classCouplingCol.SortIndicator = true;
            classCouplingCol.SortColumnId  = 0;
            classCouplingCol.Reorderable   = true;
            classCouplingCol.Resizable     = false;
            treeviewMetrics.AppendColumn(classCouplingCol);

            realLocCol = new TreeViewColumn(GettextCatalog.GetString("Real Loc"), new CellRendererText(), "text", 4);
            realLocCol.SortIndicator = true;
            realLocCol.SortColumnId  = 0;
            realLocCol.Reorderable   = true;
            realLocCol.Resizable     = false;
            treeviewMetrics.AppendColumn(realLocCol);

            commentsLocCol = new TreeViewColumn(GettextCatalog.GetString("Comments Loc"), new CellRendererText(), "text", 5);
            commentsLocCol.SortIndicator = true;
            commentsLocCol.SortColumnId  = 0;
            commentsLocCol.Reorderable   = true;
            commentsLocCol.Resizable     = false;
            treeviewMetrics.AppendColumn(commentsLocCol);

            // TODO: When user clicks on the respective type then the corresponding filename containing that type should open

            this.treeviewMetrics.RowActivated += delegate {
                Gtk.TreeIter selectedIter;
                if (treeviewMetrics.Selection.GetSelected(out selectedIter))
                {
                    rowSelectTypeName = (IProperties)metricStore.GetValue(selectedIter, 6);
                    MonoDevelop.Ide.IdeApp.Workbench.OpenDocument(rowSelectTypeName.FilePath);
                    MonoDevelop.Ide.IdeApp.Workbench.ActiveDocument.TextEditor.JumpTo(rowSelectTypeName.StartLine, 0);
                }
            };

            this.treeviewMetrics.CursorChanged += delegate {
                Gtk.TreeIter selectedIter;
                if (treeviewMetrics.Selection.GetSelected(out selectedIter))
                {
                    rowSelectTypeName = (IProperties)metricStore.GetValue(selectedIter, 6);
                    Gtk.Application.Invoke(delegate {
                        textviewReport.Buffer.Text = CodeMetricsService.GenerateTypeMetricText(rowSelectTypeName);
                    });
                }
            };
        }