private void PrepareData()
        {
            networks = new AbstractNetwork[RealizationCount];
            NetworkStatuses = new NetworkEventArgs[RealizationCount];
            for (int i = 0; i < RealizationCount; ++i)
            {
                ModelTypeInfo[] info = (ModelTypeInfo[])ModelType.GetType().GetField(ModelType.ToString()).GetCustomAttributes(typeof(ModelTypeInfo), false);
                Type t = Type.GetType(info[0].Implementation);
                Type[] constructTypes = new Type[] {
                    typeof(String),
                    typeof(Dictionary<ResearchParameter, object>),
                    typeof(Dictionary<GenerationParameter, object>),
                    typeof(AnalyzeOption) };
                object[] invokeParams = new object[] {
                    ResearchName,
                    ResearchParamaterValues,
                    GenerationParameterValues,
                    AnalyzeOptions };
                networks[i] = (AbstractNetwork)t.GetConstructor(constructTypes).Invoke(invokeParams);

                networks[i].NetworkID = i;
                networks[i].OnUpdateStatus += new NetworkStatusUpdateHandler(AbstractEnsembleManager_OnUpdateNetworkStatus);

                NetworkStatuses[i] = new NetworkEventArgs();
                NetworkStatuses[i].ID = i;
            }

            int threadCount = Math.Min(networks.Length, Environment.ProcessorCount);
            // Creating thread related members
            threads = new Thread[threadCount];
            waitHandles = new AutoResetEvent[threadCount];
            threadData = new ThreadEntryData[threadCount];

            // Initialize threads and handles
            for (int i = 0; i < threadCount; ++i)
            {
                waitHandles[i] = new AutoResetEvent(false);
                threadData[i] = new ThreadEntryData(threadCount, i);
                threads[i] = new Thread(new ParameterizedThreadStart(ThreadEntry)) { Priority = ThreadPriority.Lowest };
            }
        }
 public EnsembleEventArgs(NetworkEventArgs networkArgs)
 {
     UpdatedNetworkID = networkArgs.ID;
     UpdatedStatus = networkArgs.Status;
     UpdatedExtendedInfo = networkArgs.ExtendedInfo;
 }
 private void AbstractResearch_OnUpdateNetworkStatus(object sender, NetworkEventArgs e)
 {
     switch (e.Status)
     {
         case NetworkStatus.StepCompleted:
             StatusInfo = new ResearchStatusInfo(ResearchStatus.Running, StatusInfo.CompletedStepsCount + 1);
             break;
         case NetworkStatus.Failed:
             StatusInfo = new ResearchStatusInfo(ResearchStatus.Failed, StatusInfo.CompletedStepsCount);
             break;
         default:
             Debug.Assert(false);
             break;
     }
 }