0

Possible Duplicate:
C#: Triggering an Event when an object is added to a Queue

I am developing a downloader program. And I want to use fifo. My queue must be dynamic. Some event handler can add an object to my list, then a certain event must run and get an item of the queue and download it. Repeating for next item, and so on.

I am not sure that I explained my aim well. I just want to use a dynamic structure. I looked into the Queue class, but it hasn't any event on an item being added. Users can add link to my queue and it will download it item by item. If a new item is added, some event must fire and downloading of it must either start or the item should be placed into the queue.

Secondly, Is there any alternative for FIFO?

Community
  • 1
  • 1
unbalanced
  • 1,192
  • 5
  • 19
  • 44
  • Before you select a datastructure, design your solution (algorithm). – H H Aug 01 '12 at 12:31
  • I will but firstly I want to know how can I use event for Que – unbalanced Aug 01 '12 at 12:32
  • Maybe you need Threads or Tasks instead of events. Using C#5 already? – H H Aug 01 '12 at 12:35
  • @HenkHolterman, yes its. Do you advise me to use Queue? – unbalanced Aug 01 '12 at 12:37
  • 1
    I've corrected your spelling and grammer but its not clear exactly wha you are asking. – Jodrell Aug 01 '12 at 12:37
  • @Jodrell, thanx but I really dont know how to explain it.let me try again. I have a list which will be downloaded. When an item of list downloded, it will download next item, here is ok. and if an item adds list, I must know that it added. So I think that I need an event or like that in Queue class. But I doesnt support any event for it. And I thought there can be another way or I must write my own event for it – unbalanced Aug 01 '12 at 12:42
  • My first thought is, if you are writing the code that adds to the queue, why do you need an event? Do you want the queue processing to be asynchronous? Is that what you mean by dynamic? – Jodrell Aug 01 '12 at 13:34
  • this link works for me.. thank you http://stackoverflow.com/questions/531438/c-triggering-an-event-when-an-object-is-added-to-a-queue – unbalanced Aug 01 '12 at 13:35

0 Answers0