J
jzlondon
Hi,
I have a question that I wonder if someone might be able to help me with...
I have an application which handles real-time financial data from a third
party source. The data comes in via events which are fired on an arbitrary
thread, and I then take the data, generate update commands for a SQL Server
database, and add them to a queue using a lock on a sync object to ensure
thread safety when writing to the queue.
I then have a background worker thread which watches the queue and executes
the queries inside it sequentially. Again, the reading and dequeuing is
synchronised with the writing.
So far, so good.
I also have a need to execute some other, fairly slow running, queries
against the database. These queries will return results and will be running
in an arbitrary thread. The question I have is about thread safety around
the SQLConnection object. So far, I've avoided locking on it, as I only
have one thread (the worker) accessing it at any point.
Do I need to synchronise access to the connection object? If so, can I open
a separate connection and sync that, leaving the first connection free to
process the updates, or will connection pooling interfere and give me any
problems?
Thanks in advance for any advice you may have,
James Cane
ps. .Net 2.0, C#, SQL Server 2005.
I have a question that I wonder if someone might be able to help me with...
I have an application which handles real-time financial data from a third
party source. The data comes in via events which are fired on an arbitrary
thread, and I then take the data, generate update commands for a SQL Server
database, and add them to a queue using a lock on a sync object to ensure
thread safety when writing to the queue.
I then have a background worker thread which watches the queue and executes
the queries inside it sequentially. Again, the reading and dequeuing is
synchronised with the writing.
So far, so good.
I also have a need to execute some other, fairly slow running, queries
against the database. These queries will return results and will be running
in an arbitrary thread. The question I have is about thread safety around
the SQLConnection object. So far, I've avoided locking on it, as I only
have one thread (the worker) accessing it at any point.
Do I need to synchronise access to the connection object? If so, can I open
a separate connection and sync that, leaving the first connection free to
process the updates, or will connection pooling interfere and give me any
problems?
Thanks in advance for any advice you may have,
James Cane
ps. .Net 2.0, C#, SQL Server 2005.