Thursday 15 August 2013

C# Wait until the object has been inserted to the list (freeze application) -


I've stumbled over an annoying problem. I have a timer that gives priority to a list (generics) every 250 MB (1-5 objects in the list) and if it "completes" the criteria, then it should add an object to the "undisclosed list" but the problem is That sometimes it ignores the list and so through (even if it should be added before 250ms).

So my question is, what the best way does not add the object to tell it to ensure that the object can not be added to the list (now everything is running on the main thread is)?

  // This method is called zero check () {foreign language (getAllG) in GetAllInList {InIgnoreList (G); }} // InIgnoreList (g) Zero InIgnoreList (g) {foreach (var b in g.List ()) {if (unknown list. Axis (x => x.Name == g.Name) break; // New method, where I add it, but sometimes IgnoreList.Exists are checked}}   

thanks :)

< Div class = "text" itemprop = "text">

It seems that you are facing a race condition - it may be that check () to the previous Calling before being called

); Zero inquiry () {lockObject} {foreach (getAll g in GetAllInList) {InIgnoreList (g); }}}

Alternatively, you can define the use of lock in combination with a bool flag if Check () method is still running before the call when the timer event is activated.

No comments:

Post a Comment