老项目环境为.net3.5,遇到数据统计情况,就想到用类似于4.0以上的task写法。
说明,此种写法比较适用于数据量比较大的情况下,没有分库分表数据存储量为几十上百万左右适用。
参考:https://docs.microsoft.com/zh-cn/dotnet/api/system.threading.waithandle?view=netframework-3.5
using (var mrEvent1 = new ManualResetEvent(false))
using (var mrEvent2 = new ManualResetEvent(false))
using (var mrEvent3 = new ManualResetEvent(false))
using (var mrEvent4 = new ManualResetEvent(false))
{
ThreadPool.QueueUserWorkItem(delegate
{
try
{
houseCount = svr.GetEaBuildHouseCount(Token, eaBuildCode);
}
catch (Exception ex)
{
Log4net.Error(this, ex);
}
finally
{
mrEvent1.Set();
}
});
ThreadPool.QueueUserWorkItem(delegate
{
try
{
yPayHouse = svr.GetEaBuildPayHouseCountSum(Token, eaBuildCode);
}
catch (E