use asynchronous representatives threadpool.queueuserworkitem large parallelism?
i have .net concentration processes around 300,000 annals collection import, takes few seconds per record i parallelize this. following code, what's inadequacy between processwithansycdelegates()
processwiththreadpool()
?
public category resultnotification
{ open eventhandler eventuality success;
open eventhandler eventuality fail;
middle vacant notify(bool sucess) {if (success) success(); else fail();}
}
public stationary category processor
{ open resultnotification processwithansycdelegates(record record)
{ var r = new resultnotification();
func<record,bool> processrecord=new recordprocessor().processrecord;
processrecord.begininvoke
( record
,ar => result.notify(processrecord.endinvoke(ar))
,null);
relapse r;
}
open resultnotification processwiththreadpool(record r)
{ var r = new resultnotification();
var rp = new recordprocessor();
threadpool.queueworkuseritem(_=>result.notify(rp.processrecord(r)));
relapse r;
}
}
Comments
Post a Comment