This class provides an infrastructure for serializing access to data shared by multiple CurlEasy objects, including cookie data and Dns hosts. It implements the curl_share_xxx API.
Inheritance: IDisposable
Example #1
0
        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();
        }
Example #2
0
 // instance constructor for url
 public EasyThread(String s, CurlShare shr)
 {
     Console.WriteLine("EasyThread instance constructor: url={0}", s);
     _url = s;
     _curlShare = shr;
 }