namespace test
{
using System;
using System.IO;
using System.Runtime.InteropServices;
using System.Diagnostics;
using System.Collections;
class test
{
public static void Main(string[] args)
{
Queue queue = new Queue();
string tmp;
for (int i=0;i<50;i++) {
queue.Enqueue("Data #"+i);
}
/*
foreach ( System.Object item in queue ) {
Console.WriteLine("showing: {0}",item);
}
*/
while(queue.Count>0){
tmp = (string) queue.Dequeue();
Console.WriteLine("showing: {0}",tmp);
}
}
}
}
Problem is, the output I get is:
showing: Data #0 showing: Data #1 showing: Data #2 showing: Data #3 showing: Data #4 showing: Data #5 showing: Data #6 showing: Data #7 showing: Data #8 showing: Data #9 showing: Data #10 showing: Data #11 showing: Data #12 showing: Data #13 showing: Data #14 showing: Data #15 showing: Data #0 showing: Data #1 showing: Data #2 showing: Data #3 showing: Data #4 showing: Data #5 showing: Data #6 showing: Data #7 showing: Data #8 showing: Data #9 showing: Data #10 showing: Data #11 showing: Data #12 showing: Data #13 showing: Data #14 showing: Data #15 showing: Data #0 showing: Data #1 showing: Data #2 showing: Data #3 showing: Data #4 showing: Data #5 showing: Data #6 showing: Data #7 showing: Data #8 showing: Data #9 showing: Data #10 showing: Data #11 showing: Data #12 showing: Data #13 showing: Data #14 showing: Data #15 showing: Data #0 showing: Data #1
On Sat, 2002-10-12 at 05:15, Vladimir Vukicevic wrote:
On Fri, 2002-10-11 at 19:44, Pablo Baena wrote:
> The last problem I showed here is not ThreadNotify's fault. Seems to
> be a bug in Queue.Dequeue.
> If you look at the output of the test, you will notice it isn't
> accurate to the data in the queue when you use Dequeue, but the
> commented part with foreach works fine.
This test seems to work fine for me... I have it putting in the lines of
data and then dequeueing the same lines in the same order. The lock
statements are necessary when you use the queue between threads; you
want to lock (queue) { operations_on_queue_here; }, since the queue
itself doesn't do any locking. What output are you seeing that's
broken? I'd also suggest not using ls for a test case, because of the
possibility of ls sending bizzarely formatted output that could be
confusing the reader (the chances of this are almost zero, but still..)
- Vlad
--
Vladimir Vukicevic <[EMAIL PROTECTED]>
<Tetsuo> la vida es muy ironica vio? <Ranma> sip la verdad que se nos esta cagando de risa! <Ranma> y la voy a cagar a piñas |
