Note that there are some explanatory texts on larger screens.

plurals
  1. PODatabase operation via Threadpool or Asyn programming
    primarykey
    data
    text
    <p>i have database with larger number of records.(database values are updated via a webservice)</p> <p>Each record/row is of type (id,xmlfilename,operation,parameters,operationId,status) ie. we have perform operation as specified by'operation' on a xmlfile specified by "xmlfilename" with parameters for operation specified by "parameters".. status part is "intially" free as is updated as when reqd.</p> <p>I have to do these (each row) operation using Threads..ie one thread per 'id' number of entries.as long as there are 'id' rows in db fetch and perform "operation" </p> <p>how can i do this efficiently with maximum parallelism and/or concurrency.</p> <p>Is there a better way? </p> <p>What is best suited Threadpool or custom threads or asyn programming? </p> <p><b>Edit Added:Here is pseudo code i tried </b></p> <pre><code>string operationId=null; while(operationId = DBWorker.getNextFreeOperationId ()) //how do i check this?another query??untill there are operations with status "Free" //,keep selecting operationids //note db is updating asynchronously. { //retrieve all rows with operationid=operationId eg:800 . 1 thread/qid???? and // status="free" ... //there are multiple operations with same operationIds DataRowCollection dbRows=DBWorker.retrieveQueuedEntries(operationId); MyWorkItem workItem = new DBWorker.MyWorkItem(); workItem.DataRows = dbRows; workItem.Event = new AutoResetEvent(false); //MyWorkItem.DoWork will do the necessary "Operation" ThreadPool.QueueUserWorkItem(new WaitCallback(workItem.DoWork),workItem); } -------------- MyWorkItem.DoWork(obj x){ //for brevity for each DataRow row in this.DataRows { performOperation(row);//use row["operation"] .. } --------------- bool performOperation(DataRow row) { string operation = (string)row["operation"];//retrieve other similarly switch(operation) { case Operations.Add: //call Add operation .. ... } } ------------ </code></pre> <p>above code is using.net2.0.. doesnt achieve multithreading .. scenario may be the database is updating from one end asynchronously,while above code will be running as windows service at the same time.</p> <p>thx<br> Amit</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload