Alright i have an application which starts hundreds of crawling tasks at the same time and those tasks adds hundreds of found urls into a dictionary
I am using lock to add each found url however i see that all threads are waiting at lock (it works but i am looking for faster working way if there is any)
I wonder are there any better way for me to improve performance
The application is .net 4.5.1 c#-5 WPF application
This is my dictionary definition
private static Dictionary<string, UrlHolder> dicUrlHolder = new Dictionary<string, UrlHolder>();
This is how i use
lock (dicUrlHolder)
{
//do stuff here each time gets a lock
}
So i wonder any other better way to use it between hundreds of threads locking concurrently hundreds of times to add / update
You can use ConcurrentDictionary<TKey, TValue> Class
http://msdn.microsoft.com/en-us/library/dd287191(v=vs.110).aspx
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.