Exemplo n.º 1
0
    public static void run(String[] args)
    {
        try {
            Curl.GlobalInit((int)CURLinitFlag.CURL_GLOBAL_ALL);

            dnsLock    = new Object();
            cookieLock = new Object();

            Share share              = new Share();
            Share.LockFunction   lf  = new Share.LockFunction(OnLock);
            Share.UnlockFunction ulf = new Share.UnlockFunction(OnUnlock);
            share.SetOpt(CURLSHoption.CURLSHOPT_LOCKFUNC, lf);
            share.SetOpt(CURLSHoption.CURLSHOPT_UNLOCKFUNC, ulf);
            share.SetOpt(CURLSHoption.CURLSHOPT_SHARE,
                         CURLlockData.CURL_LOCK_DATA_COOKIE);
            share.SetOpt(CURLSHoption.CURLSHOPT_SHARE,
                         CURLlockData.CURL_LOCK_DATA_DNS);

            EasyThread et1 = new EasyThread(args[0], share);
            EasyThread et2 = new EasyThread(args[1], share);
            Thread     t1  = new Thread(new ThreadStart(et1.ThreadFunc));
            Thread     t2  = new Thread(new ThreadStart(et2.ThreadFunc));
            t1.Start();
            t2.Start();
            t1.Join();
            t2.Join();

            share.Cleanup();
            Curl.GlobalCleanup();
        }
        catch (Exception ex) {
            Console.WriteLine(ex);
        }
    }