Пример #1
0
 protected override void PreStart()
 {
     client = new HttpClient();
 }
Пример #2
0
        private void _fetchFromSina()
        {
            client = new HttpClient();
            List<string> queryString = new List<string>();
            bool isSent = false;
            if (lastClosePriceDatas.Count != 0)
            {
                int i = 0;
                int n = 150;
                StringBuilder sb = new StringBuilder();
                foreach(var data in lastClosePriceDatas.Values)
                {
                    i++;
                    isSent = false;
                    sb.Append(data.Alias);
                    sb.Append(",");

                    // 构建query string
                    if (i % n == (n - 1))
                    {
                        sb.Remove(sb.Length - 1, 1);
                        queryString.Add(sb.ToString());
                        sb.Clear();
                        isSent = true;
                    }
                }
                if (!isSent)
                {
                    sb.Remove(sb.Length - 1, 1);
                    queryString.Add(sb.ToString());
                }
            }

            foreach (string item in queryString)
            {
                _sendRequest(item);
            }
        }