c# - MultiThreading and LINQ and CPU usage -
i have selected data database , fill datatable.
also have 10 threads select needed data datatable.
when these threads started concurrently, cpu usage goes 100%.
void trd1_task(datatable mydatatable, int64 thiscode) { datatable dt1 = (from x in mydatatable.asenumerable() x.field<int64>("code") == thiscode select x).copytodatatable(); } what should do?
thanks.
i'm using linq sql
no, you're not. here:
void trd1_task(datatable mydatatable, int64 thiscode) that's not using linq sql. that's using datatable. means you've fetched all data process. don't that.
if using linq sql, query like:
var query = user in dbcontext.users user.code == thiscode select user; you may have used linq sql fetch data datatable, if then:
- it's odd use
datatable@ all, when presumably you've got strongly-typed model - the fact you're filtering after you've fetched data makes hideously inefficient - want filtering performed in database itself.
the cpu problem side-effect of fact shouldn't have data in process in first place.
Comments
Post a Comment