D
Daniel
Hi all
I wrote an App that checks some Emailaddresses from our Database ( more
than 500'000). So I wrote a Multithread App.
I have a Queue defined as follow:
ProducerConsumer prcEmailProcess = new ProducerConsumer();
I start the Threads with the following Command:
for (int i = 0; i < MaxThread; i++)
new Thread(new ThreadStart(EmailChecker)).Start();
Then I add for each Thread a null object to signalize the End:
for (int i = 0; i < MaxThread; i++)
prcEmailProcess.Produce(null);
The EmailChecker Code looks as follow:
void EmailChecker()
{
while (bolCheckEmail)
{
object o = prcEmailProcess.Consume();
if (o == null)
{
lock (listDNSLock)
{
if (intEnd.Equals(MaxThread - 1))
{
prcEmailProcess.Reset();
bolCheckEmail = false;
break;
}
else
{
intEnd++;
break;
}
}
}
else
{
objEmail = (ILLFEmail)o;
try
{
//Do somthing }
catch
{
//Handle the Error
}
finally
{
//Clean up
}
}
}
}
Now I would like to show on the MainForm in a lable which thread is
working on with Emailaddress.
I have for each thread a lable.
How can I do this?
I wait till the variable bolCheckEmail is false. But somtimes the
variable is false but the program seams still to run (when I exit the
main form, there is still a process running).
How can that be?
thanks for your help
Daniel
I wrote an App that checks some Emailaddresses from our Database ( more
than 500'000). So I wrote a Multithread App.
I have a Queue defined as follow:
ProducerConsumer prcEmailProcess = new ProducerConsumer();
I start the Threads with the following Command:
for (int i = 0; i < MaxThread; i++)
new Thread(new ThreadStart(EmailChecker)).Start();
Then I add for each Thread a null object to signalize the End:
for (int i = 0; i < MaxThread; i++)
prcEmailProcess.Produce(null);
The EmailChecker Code looks as follow:
void EmailChecker()
{
while (bolCheckEmail)
{
object o = prcEmailProcess.Consume();
if (o == null)
{
lock (listDNSLock)
{
if (intEnd.Equals(MaxThread - 1))
{
prcEmailProcess.Reset();
bolCheckEmail = false;
break;
}
else
{
intEnd++;
break;
}
}
}
else
{
objEmail = (ILLFEmail)o;
try
{
//Do somthing }
catch
{
//Handle the Error
}
finally
{
//Clean up
}
}
}
}
Now I would like to show on the MainForm in a lable which thread is
working on with Emailaddress.
I have for each thread a lable.
How can I do this?
I wait till the variable bolCheckEmail is false. But somtimes the
variable is false but the program seams still to run (when I exit the
main form, there is still a process running).
How can that be?
thanks for your help
Daniel