curl_share_xxx
public static void Main(String[] args) { try { Curl.GlobalInit(CurlInitFlag.All); dnsLock = new Object(); cookieLock = new Object(); var urls = new[] { "http://www.codeplex.com", "http://www.yahoo.com", "http://www.cnn.com", "http://www.abc.com", "http://www.bbc.co.uk" }; using (var share = new CurlShare()) { share.LockFunction = OnLock; share.UnlockFunction = OnUnlock; share.Share = CurlLockData.Cookie; share.Share = CurlLockData.Dns; var workers = new List<Thread>(); foreach (var url in urls) { var et = new EasyThread(url, share); var thread = new Thread(et.ThreadFunc); workers.Add(thread); thread.Start(); } foreach (var thread in workers) { thread.Join(); } } Curl.GlobalCleanup(); } catch (Exception ex) { Console.WriteLine(ex); } Console.ReadLine(); }
// instance constructor for url public EasyThread(String s, CurlShare shr) { Console.WriteLine("EasyThread instance constructor: url={0}", s); _url = s; _curlShare = shr; }