-1

I have one database stored on cloud that has table which I am accessing. The table has columns like "FileName", "ID" , etc etc. After accessing the database I am saving FileName in a datatable. This is an image database where FileName acts as a pointer to original image.

I have part of code that access database and downloads Image from database. I want one thread to perform task of accessing database and feeding it to the queue. Another thread will perform operations on data from queue and then that item will be removed.

I am trying to use BlockingCollections but not sure what type of Queue I should use. Can somebody help?

Gaurav K.
  • 67
  • 2
  • 3
  • 10
  • This is a classic Producer-Consumer pattern. Take a look at this question: http://stackoverflow.com/questions/1656404/c-sharp-producer-consumer – king_nak Mar 31 '14 at 13:40

2 Answers2

2

I think ConcurrentQueue is what you are looking for. For more information, ConcurrentQueue MSDN

EDIT :

You can use public bool TryDequeue(out T result) method. It basically implement try pattern to by pass an exception when it occurs.

cat916
  • 1,363
  • 10
  • 18
-1

You can make use of a Synchronized Queue. Synchronized is a thread safe wrapper for the standard Queue class.

BBlake
  • 2,388
  • 1
  • 22
  • 31