P
Paul Bowman
Hi All
Does anybody have any ideas what I am doing wrong with this code.
What I am trying to do is read data from a Domino Database. For
purposes of the test I have wrapped the DominoCom object in a C# class
that runs in a seperate thread.
If I run this code:
rd = new ReadData(src, 1, 10, this);
list.Add(rd);
t = new Thread(new ThreadStart(rd.Read));
t.Name = "Thread " + ++ThreadId;
t.Start();
rd = new ReadData(src, 30, 20, this);
list.Add(rd);
t = new Thread(new ThreadStart(rd.Read));
t.Name = "Thread " + ++ThreadId;
t.Start();
rd = new ReadData(src, 100, 30, this);
list.Add(rd);
t = new Thread(new ThreadStart(rd.Read));
t.Name = "Thread " + ++ThreadId;
t.Start();
Which starts three threads it all works as I would expect
but if I do it in a loop (which is what I want to do) the code stops
at the
point where it calls into the Domino COM Class.
list = new ArrayList(10);
while (!isComplete)
{
if (list.Count < 10)
{
rd = new ReadData(src, offset * 10 + 1, docCount, this);
list.Add(rd);
t = new Thread(new ThreadStart(rd.Read));
t.Name = "Thread " + ++ThreadId;
t.Start();
offset++;
rd = null;
t = null;
}
}
What I dont understand is why this should be any different to starting
each thread as per the previous example...
If anybody has any ideas I would be grateful...
Regards
Paul Bowman
Does anybody have any ideas what I am doing wrong with this code.
What I am trying to do is read data from a Domino Database. For
purposes of the test I have wrapped the DominoCom object in a C# class
that runs in a seperate thread.
If I run this code:
rd = new ReadData(src, 1, 10, this);
list.Add(rd);
t = new Thread(new ThreadStart(rd.Read));
t.Name = "Thread " + ++ThreadId;
t.Start();
rd = new ReadData(src, 30, 20, this);
list.Add(rd);
t = new Thread(new ThreadStart(rd.Read));
t.Name = "Thread " + ++ThreadId;
t.Start();
rd = new ReadData(src, 100, 30, this);
list.Add(rd);
t = new Thread(new ThreadStart(rd.Read));
t.Name = "Thread " + ++ThreadId;
t.Start();
Which starts three threads it all works as I would expect
but if I do it in a loop (which is what I want to do) the code stops
at the
point where it calls into the Domino COM Class.
list = new ArrayList(10);
while (!isComplete)
{
if (list.Count < 10)
{
rd = new ReadData(src, offset * 10 + 1, docCount, this);
list.Add(rd);
t = new Thread(new ThreadStart(rd.Read));
t.Name = "Thread " + ++ThreadId;
t.Start();
offset++;
rd = null;
t = null;
}
}
What I dont understand is why this should be any different to starting
each thread as per the previous example...
If anybody has any ideas I would be grateful...
Regards
Paul Bowman