Should the stream "store in the DB" be started? It seems that perhaps the best option (if possible) is for the poll thread to scroll through another thread to save. Depending on the number of threads created, it may be that using the first poll thread ThreadPool.QueueUserWorkItem () may be a more efficient route.
For greater efficiency, when saving to the database, I will use asynchronous I / O in the database, rather than synchronization methods.
Anytime you can get away from communicating directly between two threads, you should. To compose some synchronization primitives, your code will not be so easy to debug and may introduce some very subtle race conditions that cause once-in-a-million errors (which are not so fun to find / fix).
If the second thread always needs to be executed, let us know why with additional information, and we can return with a more detailed answer.
Good luck
source share