Exemple #1
0
        /// <summary>
        /// 添加HTML标题获取客户端
        /// </summary>
        /// <param name="client">HTML标题获取客户端</param>
        /// <returns></returns>
        internal int Push(HttpClient client)
        {
START:
            while (System.Threading.Interlocked.CompareExchange(ref clientLock, 1, 0) != 0)
            {
                AutoCSer.Threading.ThreadYield.Yield(AutoCSer.Threading.ThreadYield.Type.HtmlTitleHttpClient);
            }
            if (!uris.IsEmpty)
            {
                Uri uri = uris.UnsafePopOnly();
                clientLock = 0;
                try
                {
                    if (client.Get(uri))
                    {
                        return(0);
                    }
                }
                catch (Exception error)
                {
                    Log.add(AutoCSer.Log.LogType.Error, error);
                }
                try
                {
                    uri.Cancel();
                }
                catch (Exception error)
                {
                    Log.add(AutoCSer.Log.LogType.Error, error);
                }
                goto START;
            }
            if (isDisposed == 0)
            {
                clients[clientIndex++] = client;
                clientLock             = 0;
                return(0);
            }
            --clientCount;
            clientLock = 0;
            return(1);
        }
Exemple #2
0
        /// <summary>
        /// 添加HTML标题获取客户端
        /// </summary>
        /// <param name="client">HTML标题获取客户端</param>
        /// <returns></returns>
        internal int Push(HttpClient client)
        {
START:
            clientLock.EnterYield();
            if (!uris.IsEmpty)
            {
                Uri uri = uris.UnsafePopOnly();
                clientLock.Exit();
                try
                {
                    if (client.Get(uri))
                    {
                        return(0);
                    }
                }
                catch (Exception error)
                {
                    Log.Exception(error, null, LogLevel.Exception | LogLevel.AutoCSer);
                }
                try
                {
                    uri.Cancel();
                }
                catch (Exception error)
                {
                    Log.Exception(error, null, LogLevel.Exception | LogLevel.AutoCSer);
                }
                goto START;
            }
            if (isDisposed == 0)
            {
                clients[clientIndex++] = client;
                clientLock.Exit();
                return(0);
            }
            --clientCount;
            clientLock.Exit();
            return(1);
        }