예제 #1
0
        private async void button1_Click(object sender, RoutedEventArgs e)
        {
            await Task.Run(() =>
            {
                Dispatcher.BeginInvoke(() =>
                {
                    progressBar1.IsIndeterminate = true;
                });

                SendPost();
                //Thread.Sleep(2000);
                //for (int i = 0; i < 200; i++)
                //{
                //    Thread.Sleep(10);
                //}

                Dispatcher.BeginInvoke(() =>
                {
                    progressBar1.IsIndeterminate = false;
                });
            });

            return;

            CookieAwareClient cookieClient = new CookieAwareClient();

            //cookieClient.Headers["X-Requested-With"] = "XMLHttpRequest";
            //cookieClient.DownloadStringCompleted += new DownloadStringCompletedEventHandler(cookieAttempt_DownloadStringCompleted);
            //cookieClient.DownloadStringAsync(new Uri("http://love.163.com/operation/activities"));


            cookieClient.Headers["Content-Type"] = "application/x-www-form-urlencoded; charset=UTF-8;";
            cookieClient.UploadStringAsync(new Uri("http://love.163.com/home/newInfo"), "POST", HttpUtility.UrlEncode(string.Format("height=162-165&age=25-27&city=0&province=1&lastTrendTime={0}", Convert.ToInt64(DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0)))));
            cookieClient.UploadStringCompleted += cookieClient_UploadStringCompleted;
        }
예제 #2
0
        public async void GetLatestVisitor()
        {
            await Task.Run(() =>
            {
                Dispatcher.BeginInvoke(() =>
                {
                    ApplicationBar.Mode = ApplicationBarMode.Minimized;

                    progressBar1.IsIndeterminate = true;
                    if (list_message.Items.Count > 0)
                    {
                        list_message.ScrollIntoView(list_message.Items[0]);
                        list_message.UpdateLayout();
                    }
                });

                CookieAwareClient cookieClient = new CookieAwareClient();

                //cookieClient.Headers["X-Requested-With"] = "XMLHttpRequest";
                cookieClient.DownloadStringCompleted += new DownloadStringCompletedEventHandler(cookieAttempt_DownloadStringCompleted);
                cookieClient.DownloadStringAsync(new Uri(URL, UriKind.Absolute));


                //cookieClient.Headers["Content-Type"] = "application/x-www-form-urlencoded; charset=UTF-8;";
                //cookieClient.UploadStringAsync(new Uri("http://love.163.com/home/newInfo"), "POST", HttpUtility.UrlEncode(string.Format("height=162-165&age=25-27&city=0&province=1&lastTrendTime={0}", Convert.ToInt64(DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0)))));
                //cookieClient.UploadStringCompleted += cookieClient_UploadStringCompleted;
            });
        }