There is not enough information to suggest the way you should go, but given what you could do, it would be a parallel task library and Task<T> .
Downloading fun. However, do not go crazy with this, you can easily end up with your multi-threaded multi-threaded effort slower than your synchronized batch.
If we say that T, connected to db, threw a request at it, returned the datareader and said that there were 8 requests in the packet.
You set tasks from 0 to 7, start a timer for a timeout, turn off everything. Upon completion, you save the readerr and set the bit of your flag based on the task identifier. When it gets to 255, raise the OnBatchComplete event, copy your readers and pass them to the merge task. The timeout is turned off first, proceed accordingly. If there is an error in the task, return some suitable reason to it, call the caller, possibly killing the queries that are still in progress.
I donβt know how your combined process works, but if it can be organized like this, say that when requests 1 and 3 are ready, you can do an intermediate process or if it is in some logical order, as soon as all requests are ready for reading, you could start reading in simple classes, and then throw each of them into the task of the combine ....
It's not fair, I donβt get such funny things ....
source share