Public voidGeneratedata (stringdbfullname) { BOOLbsuccess =true; if(File.exists (dbfullname)) {file.delete (dbfullname); } System.Data.SQLite.SQLiteConnection.CreateFile (Dbfullname); if(File.exists (dbfullname)) {sqlitehelper.connectionstring=Sqlitehelper.getconn (dbfullname); Bsuccess= Sqlitehelper.initgeneratedb (New string[] {commongeneratedata.createbuildingtype, commongeneratedata.createlocationb Asicinfo, Commongeneratedata.createlocationotherinfo, Commongeneratedata.createele Location, commongeneratedata.createelelocationpct, Commongeneratedata.createlocati Onattach, commongeneratedata.createelection}); using(Sqliteconnection Sqliteconn =Newsqliteconnection (sqlitehelper.connectionstring)) {Sqliteconn.open (); List<Action<SQLiteTransaction>> delegetlist =NewList<action<sqlitetransaction>>() {commongeneratedata.generatebuildingtype, Commongeneratedata.gener Atelocationbasicinfo, Commongeneratedata.generatelocationotherinfo, Commonge Neratedata.generateelelocation, commongeneratedata.generateelelocationpct, C Ommongeneratedata.generatelocationattach, commongeneratedata.generateelection}; Waithandle[] Waithandles=Newwaithandle[]{NewAutoResetEvent (false), NewAutoResetEvent (false), NewAutoResetEvent (false), NewAutoResetEvent (false), NewAutoResetEvent (false), NewAutoResetEvent (false), NewAutoResetEvent (false) }; using(Sqlitetransaction tran =sqliteconn.begintransaction ()) { for(inti =0; I < Delegetlist. Count; i++) {Action<SQLiteTransaction> Deleget =Delegetlist[i]; AutoResetEvent resetevent=(AutoResetEvent) waithandles[i]; ThreadPool.QueueUserWorkItem (StateInfo={deleget (tran); Resetevent.set (); }, Waithandles[i]); } waithandle.waitall (Waithandles); Tran.commit (); } sqliteconn.close (); } } }
Usage of thread pool in project