I had a multi-threaded TCP server software written in C#. Many of the threads should read from database and i am using SqlDataReader for reading from database. When one thread wants to read from database, there is no problem but when two or more threads want to read from database, this situation starts to be a problem. .NET gives this exception: There is already an open DataReader associated with this Command which must be closed first.
How can i prevent from the error? How can i protect SqlDataReader from multiple access? Is mutex appropriate for this problem?