| | |
| | | using DevExpress.XtraEditors; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.ComponentModel; |
| | | using System; |
| | | using System.Data; |
| | | using System.Drawing; |
| | | using System.Linq; |
| | | using System.Diagnostics; |
| | | using System.IO; |
| | | using System.Net; |
| | | using System.Text; |
| | | using System.Text.RegularExpressions; |
| | | using System.Threading.Tasks; |
| | | using System.Windows.Forms; |
| | | using System.Windows.Media.Animation; |
| | | using DevExpress.Internal.WinApi.Windows.UI.Notifications; |
| | | using DevExpress.XtraEditors; |
| | | using DevExpress.XtraRichEdit.Import.OpenXml; |
| | | using DevExpress.XtraTreeList.Data; |
| | | using Gs.DevApp.Entity; |
| | | using Gs.DevApp.ToolBox; |
| | | using Gs.DevApp.UserControl; |
| | | using Newtonsoft.Json; |
| | | |
| | | namespace Gs.DevApp.TestForm |
| | | { |
| | | public partial class XtraForm1 : DevExpress.XtraEditors.XtraForm |
| | | public partial class XtraForm1 : XtraForm |
| | | { |
| | | |
| | | //https://www.cnblogs.com/China3S/p/3452008.html |
| | | public XtraForm1() |
| | | { |
| | | InitializeComponent(); |
| | | //dddddddd(); |
| | | |
| | | //await Task.Run(() => |
| | | //{ |
| | | |
| | | //}); |
| | | } |
| | | |
| | | private async void dddddddd() { |
| | | |
| | | |
| | | UcLoading _loading = new UcLoading(); |
| | | var pgq = new PageQueryModel(1, 999999, "item_name", "asc", "", |
| | | " and fforbidstatus='A'"); |
| | | var json = JsonConvert.SerializeObject(pgq); |
| | | try |
| | | { |
| | | //var strReturn = await UtilityHelper.HttpPostAsync("", |
| | | // "MesItemsManager/GetListPageByLook", json); |
| | | //var rtn = UtilityHelper.ReturnToList(strReturn); |
| | | //var dt = rtn.rtnData; |
| | | |
| | | await csd(); |
| | | |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | MsgHelper.Warning("提示:" + ex.Message); |
| | | } |
| | | _loading.Stop(); |
| | | } |
| | | |
| | | private async Task<int> csd() |
| | | { |
| | | int c = 0; |
| | | //await Task.Delay(1000); |
| | | await Task.Run(() => |
| | | { |
| | | for (int i = 0; i < 10000; i++) |
| | | { |
| | | c = c + i; |
| | | if (richTextBox1.InvokeRequired) |
| | | { |
| | | richTextBox1.BeginInvoke(new Action(() => |
| | | { |
| | | richTextBox1.Text = c.ToString(); |
| | | })); |
| | | } |
| | | else |
| | | { |
| | | richTextBox1.Text = c.ToString(); |
| | | } |
| | | } |
| | | |
| | | }); |
| | | return c; |
| | | |
| | | } |
| | | private void simpleButton1_Click_1(object sender, EventArgs e) |
| | | { |
| | | dddddddd(); |
| | | } |
| | | |
| | | |
| | | private async void simpleButton2_Click(object sender, EventArgs e) |
| | | { |
| | | UcLoading _loading = new UcLoading(); |
| | | string url = "http://localhost:5263/"; |
| | | try |
| | | { |
| | | string result = await GetHttpResponseAsync(url); |
| | | Console.WriteLine(result); |
| | | richTextBox1.Text = result; |
| | | } |
| | | catch (WebException ex) |
| | | { |
| | | richTextBox1.Text = ex.Message; |
| | | } |
| | | _loading.Stop(); |
| | | } |
| | | |
| | | private static async Task<string> GetHttpResponseAsync(string url) |
| | | { |
| | | string param = "{}"; |
| | | HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); |
| | | |
| | | request.Method = "POST"; |
| | | request.ContentType = "application/json"; |
| | | //request.Headers.Add("token", GetBasicAuthTicket()); |
| | | request.Accept = "*/*"; |
| | | request.Timeout = 15000; |
| | | request.AllowAutoRedirect = false; |
| | | |
| | | |
| | | //StreamWriter requestStream = null; |
| | | //requestStream = new StreamWriter(request.GetRequestStream()); |
| | | //requestStream.Write(param); |
| | | //requestStream.Close(); |
| | | |
| | | using (Stream requestStream = await request.GetRequestStreamAsync()) |
| | | { |
| | | byte[] dataBytes = Encoding.UTF8.GetBytes(param); |
| | | await requestStream.WriteAsync(dataBytes, 0, dataBytes.Length); |
| | | } |
| | | |
| | | |
| | | using (WebResponse response = await request.GetResponseAsync()) |
| | | using (Stream responseStream = response.GetResponseStream()) |
| | | using (StreamReader reader = new StreamReader(responseStream, Encoding.UTF8)) |
| | | { |
| | | return await reader.ReadToEndAsync(); |
| | | } |
| | | } |
| | | } |
| | | } |