public MetricsCalculationProgressDialog(IGraph graph, MetricsCheckedList chkList, ShowMetricCalculateResult oShowMetricCalculateResult)
        {
            InitializeComponent();
            m_oMetricsCheckedList = chkList;
            m_oGraphMetricCalculatorManager = new MetricsCalculatorManager();
            m_ograph = graph;

            m_oGraphMetricCalculatorManager.CalculationProgressChanged += new ProgressChangedEventHandler(Manager_ProgressChanged);
            m_oGraphMetricCalculatorManager.CalculationCompleted += new RunWorkerCompletedEventHandler(Manager_WorksCompleted);

            m_oShowMetricCalculateResult = oShowMetricCalculateResult;
            m_oGraphMetricCalculatorManager.attach(m_oShowMetricCalculateResult);

        }
        /* Create analyzers and graph according to a "setting" object provided by outter View component; then pass to a BackgroundWorker.
         * In this project, this is invoked by a Dialog onload event handler.
         * */
        public void calculateMetricsAsync(IGraph graph, MetricsCheckedList checkedlist) {  

            if (m_oBackgroundWorker != null && m_oBackgroundWorker.IsBusy)
            {
                /*
                throw new InvalidOperationException(String.Format(
                    "{0}:{1}: An asynchronous operation is already in progress."
                    ,
                    this.ClassName,
                    MethodName
                    ));
                 * */
            }

            // logic about which calculator should be created 

            CalculateGraphMetricsAsyncArgs args = new CalculateGraphMetricsAsyncArgs(); // add analyzer to this object and pass to BackgroundWorker
            args.Analyzers = new LinkedList<AnalyzerBase>();
            args.Graph = graph;


            if (checkedlist.overall_graph_metrics == true) {args.Analyzers.AddLast(new OverallMetricCalculator()); }
            if (checkedlist.vertex_degree == true) {args.Analyzers.AddLast(new VertexDegreeCalculator()); }
            if (checkedlist.vertex_reciprocated_pair_ratio == true) {args.Analyzers.AddLast(new ReciprocatedVertexPairRatioCalculator()); }
            if (checkedlist.vertex_clustering_coefficient == true) {args.Analyzers.AddLast(new ClusteringCoefficientCalculator()); }
            if (checkedlist.vertex_pagerank == true) { args.Analyzers.AddLast(new PageRankCalculator());}
            if (checkedlist.vertex_eigenvector_centrality == true) {}
            if (checkedlist.group_metrics == true) { args.Analyzers.AddLast(new GroupMetricCalculator());} 
            
            // create a new BackgroundWorker
            m_oBackgroundWorker = new BackgroundWorker();

            m_oBackgroundWorker.WorkerReportsProgress = true;
            m_oBackgroundWorker.WorkerSupportsCancellation = true;

            m_oBackgroundWorker.DoWork += new DoWorkEventHandler(BackgroundWorker_DoWork);
            m_oBackgroundWorker.ProgressChanged += new ProgressChangedEventHandler(BackgroundWorker_ProgressChanged);
            m_oBackgroundWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(BackgroundWorker_RunWorkerCompleted);

            m_oBackgroundWorker.RunWorkerAsync(args);
        }
        private void btnCalculate_Click(object sender, EventArgs e)
        {
            //MetricsCheckedList chklist = new MetricsCheckedList();
            chklist = new MetricsCheckedList();

            if(checkedListBox1.CheckedItems.Contains("overall graph metrics")) chklist.overall_graph_metrics = true;
            if(checkedListBox1.CheckedItems.Contains("vertex degree")) chklist.vertex_degree = true;
            if(checkedListBox1.CheckedItems.Contains("vertex reciprocated pair ratio")) chklist.vertex_reciprocated_pair_ratio = true;
            if(checkedListBox1.CheckedItems.Contains("vertex clustering coefficient")) chklist.vertex_clustering_coefficient = true;
            if(checkedListBox1.CheckedItems.Contains("vertex pagerank")) chklist.vertex_pagerank = true;
            if(checkedListBox1.CheckedItems.Contains("edge reciprocation")) chklist.edge_reciprocation = true;
            if(checkedListBox1.CheckedItems.Contains("vertex eigen vector centrality")) chklist.vertex_eigenvector_centrality = true;
            if(checkedListBox1.CheckedItems.Contains("group metrics")) chklist.group_metrics = true;

            MetricsCalculationProgressDialog dg = new MetricsCalculationProgressDialog(chklist);
            if (dg.ShowDialog() == DialogResult.OK)
            {
                DialogResult = DialogResult.OK;
                this.Close();
            }
        }