public void Start() { try { using (DBDocumentStorage ds = new DBDocumentStorage(_config.DBPath)) { Threads = new Dictionary<Thread, ThreadContext>(); Dictionary<Guid, string> docs = ds.GetDocumentsList(); int c = 0; Dictionary<Guid, string> ThrList = new Dictionary<Guid, string>(); foreach(var doc in docs) { c++; if(c>= docs.Count/ ThreadCount) { Thread th = new Thread(Indexate); IndexatorThreadContext tc = new IndexatorThreadContext(ThrList, th, Thread.CurrentThread, this); th.IsBackground = true; th.Start(tc); Threads.Add(th, tc); ThrList = new Dictionary<Guid, string>(); c = 0; } ThrList.Add(doc.Key, doc.Value); } Log("Threads started", "", LogType.Message); } } catch (Exception ex) { Log(string.Format("{0} \r\n{1}", ex.Message, ex.StackTrace), "SpydeeCore", LogType.Error, "CoreConstructor"); } }
private void LoadFromDB(string ConnectionString) { DBstorage = new DBDocumentStorage(ConnectionString); docs = DBstorage.GetDocumentsList(); }