To tell you the truth, this code for the database to see Read and write ratio, the way the database is inserted data and the database locks caused by the row or page locks or table locks have a relationship, the amount of thread data based on the different settings of the server is not the same. The efficiency of lifting is more difficult to calculate. But after all, it's an attempt.
Just put it out and share it.
SqlHelper.CommandTimeout = 1800; long minAutoID = Getsourcemaxorminid (curstatdatevalue, downlogsourcedbconnstring, true); long maxautoid = getsourcemaxorminid ( Curstatdatevalue, downlogsourcedbconnstring, false); //data shards to determine the amount of data per shard long everyCount = (maxautoid - minautoid) / PartsCount + 1; List<AutoIdArea> list = new list<autoidarea> (); for (int i = 0; i < partscount; i++) { List. ADD (New autoidarea (minautoid + i * everycount, minautoid + (i + 1) * everyCount - 1, "D_copy_threadautoid_" + curstatdatevalue / 100 + "_" + i)); } utility.writelog ("Start convert detail data to original statistics to resdownloadlog_temp table", &NBSP;LOGDIR) //set Beacon Semaphore semaphores = new Semaphore (THREADCOUNT,&NBSp threadcount); //Definition Method Action<AutoIdArea, Semaphore, int> fun = (Areainfo, s, curstat) => { try { long minId = convert.toint64 ( Utility.getstatautoid (AreainFo. threadkey, areainfo.beginint, computingdb_connstring)); if (Minid <= areainfo.beginint) minId = areaInfo.BeginInt; //continue running without exception of other threads while (Import (areainfo, ref minid, curstat, downlogsourcedbconnstring) > 0) ; } catch ( EXCEPTION&NBSP;EX) { ThreadException = ex; utilitY.writelog ( string. Format ("Asynchronous Import Data exception: Beginid={0},endid={1},ex:{2}", areainfo.beginint, areainfo.endint, ex. ToString ()), logdir); utility.sendmail ("Asynchronous Import data Exception", string. Format ("Beginid={0},ENDID={1},EX:{2} ", areainfo.beginint, areainfo.endint, ex. ToString ()), false); } finally { s. Release (); } }; List<IAsyncResult> listResult = new List<IAsyncResult> (); for (int i = 0; i < list. count; i++) { semaphores. WaitOne (); if (Threadexception != null) { //waits for all asynchronous threads to finish for (int j = 0; j < listresult.count; j++) { &NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;LISTRESULT[J]. Asyncwaithandle.waitone (); } throw ThreadException; } listresult.add (fun. BeginInvoke (list[i], semaphores, curstatdatevalue, null, null)); } //waits for all asynchronous threads to finish for (int i = 0; i < listresult.count; i++) { listresult[i]. Asyncwaithandle.waitone (); } if (Threadexception != null) { throw threadexception; }
Data multi-threaded data transmission of statistics