Error With Application.DoEvents..... Help Needed

  • Thread starter Thread starter Srinivas Kollipara
  • Start date Start date
S

Srinivas Kollipara

Hey guys,
In my project one place I am using Application.DoEvents() and waiting for 5
minutes to finish my required task in that block. My project need to run for
almost 60 hours continuously to finish executing. this block which has
Application.DoEvents will run for each 2 minutes. it ran well for 20 hours
and I am getting an exception saying "Item has already been added. Key in
dictionary: "-1" Key being added: "-1""

Can Anyone help me in this....
Thanks in Advance....
Srinivas
 
Srinivas Kollipara said:
In my project one place I am using Application.DoEvents() and waiting for 5
minutes to finish my required task in that block. My project need to run for
almost 60 hours continuously to finish executing. this block which has
Application.DoEvents will run for each 2 minutes. it ran well for 20 hours
and I am getting an exception saying "Item has already been added. Key in
dictionary: "-1" Key being added: "-1""

It sounds like it isn't a DoEvents problem in particular, but adding a
duplicate key to a hashtable. Does the stacktrace of the exception not
help?

Is there any reason why you're not using threads, by the way? That's a
better way to handle background tasks, IMO.
 
Hey jon Skeet,
Thanks for response... we are using Threads in our application. when
some threads are processing, we are saying that to DoEvents()... so that
it will do paint and other stuff.... when i googled on error message. we
come to know that is about Application.DOEvents(). Do u have any idea
what might be wrong i am doing. thanks bye
 
srinivas kollipara said:
Thanks for response... we are using Threads in our application. when
some threads are processing, we are saying that to DoEvents()... so that
it will do paint and other stuff.... when i googled on error message. we
come to know that is about Application.DOEvents(). Do u have any idea
what might be wrong i am doing.

It's hard to know exactly what you're doing wrong, but you shouldn't
need to call Application.DoEvents() if you're using background threads.

Could you post a short but complete program which demonstrates the
problem?

See http://www.pobox.com/~skeet/csharp/complete.html for details of
what I mean by that.
 
Hey Jon,
the code look slike this... i cant give the exact what we are doing,
because its a company project and i should be confidential. dont mind
for this. ok

dtCurrent = DateTime.Now;
while(ht_symbol.count > processedSymbols)
{
system.windows.forms.application.doevents();
if(dtCurrent.AddMinutes(5) < DateTime.Now)
{
//doing some counter checking....
}
}


This is the only core programming block in that code.
ok thanks in advance
 
srinivas kollipara said:
the code look slike this... i cant give the exact what we are doing,
because its a company project and i should be confidential. dont mind
for this. ok

dtCurrent = DateTime.Now;
while(ht_symbol.count > processedSymbols)
{
system.windows.forms.application.doevents();
if(dtCurrent.AddMinutes(5) < DateTime.Now)
{
//doing some counter checking....
}
}


This is the only core programming block in that code.
ok thanks in advance

It's not something we can reproduce the problem with though. We don't
need to see your actual code - just a full equivalent program which
demonstrates the problem.
 
Back
Top