Tagged pages

Found 2 articles tagged with Thread

ConcurrentDictionary vs Hashtable.Synchronized
Comparison of collections in multithread environment
Basically all Dictionary collections in .NET internally implement Hashtable wrapped, so in terms of mechanism they are pretty much the same. The difference is that Dictionary exposes strong types while Hashtable uses object-object keyvalue pair which is much harder to work with because you need to know what is the actual type of the object stored in a key or value. Often casting will probably be required... read more
Avoiding high processor load in long running loops
Keep processor not overloaded with long running loops
When having a long running loop which you are not sure when it is going to end you will probably have to create a loop in a separate loop and on every iterration you will check whether some condition is true and exit the loop. Let's say you want to execute some piece of code after some specific time, let's say after one minute or everyday at specific time (common scenario in windows services). You can do it really simple with Timer class and just few lines of code as the code below. ... read more