public DataTable Enter() { DataTable dt = new DataTable(); dt.Columns.Add("交易所"); foreach (var item in CoinList) { dt.Columns.Add(item.ToString()); } for (int i = 0; i < ExChanges.Count; i++) { dt.Rows.Add(); dt.Rows[i][0] = ExChanges[i].GetExchangeName(); for (int j = 0; j < CoinList.Count; j++) { FuncHandle fh = new FuncHandle(this.AscySingle); IAsyncResult ar = fh.BeginInvoke(ExChanges[i], CoinList[j], null, fh); dt.Rows[i][j + 1] = fh.EndInvoke(ar); } } return(dt); }
// connect to the server or refresh private void Conect_btn_Click(object sender, RoutedEventArgs e) { fh = new FuncHandle(this.send_data_rev_data); AsyncCallback callback = new AsyncCallback(this.AsyncCallbackImpl); fh.BeginInvoke(callback, null); }
static void Main(string[] args) { //CommonSingle commonSingle = CommonSingle.GetInstance(); //Console.WriteLine(commonSingle.GetHashCode()); FuncHandle fh = new FuncHandle(CommonSingle.GetInstance); FuncHandle fh1 = new FuncHandle(CommonSingle.GetInstance); AsyncCallback ac = new AsyncCallback(AsyncCallbackImpl); IAsyncResult result = fh.BeginInvoke(null, fh); IAsyncResult result1 = fh1.BeginInvoke(null, fh1); CommonSingle re = fh.EndInvoke(result); CommonSingle re1 = fh1.EndInvoke(result1); Console.WriteLine("----------------"); Console.WriteLine(re.GetHashCode()); Console.WriteLine(re1.GetHashCode()); Console.WriteLine(re.Equals(re1)); /* Lazy */ LazyHandle lazyHandler= new LazyHandle(LazySingle.GetInstance); LazyHandle lazyHandler1 = new LazyHandle(LazySingle.GetInstance); IAsyncResult lazyResult = lazyHandler.BeginInvoke(null, lazyHandler); IAsyncResult lazyResult1 = lazyHandler1.BeginInvoke(null, lazyHandler1); Console.WriteLine(((LazySingle)lazyHandler.EndInvoke(lazyResult)).GetHashCode()); Console.WriteLine(((LazySingle)lazyHandler1.EndInvoke(lazyResult1)).GetHashCode()); Console.Read(); }
private void btnGKD_Click(object sender, EventArgs e) { //if (btnGKD.Text == "太慢🌶,给👴停下,下一张") //{ // btnGKD.Text = "再来1️🐙给👴👀👀"; //} btnGKD.Enabled = false; fh = new FuncHandle(this.loadData); AsyncCallback callback = new AsyncCallback(this.AsyncCallbackImpl); fh.BeginInvoke(callback, null); }
private void frmSetu_Load(object sender, EventArgs e) { Control.CheckForIllegalCrossThreadCalls = false; //reSetSize((frmSetu) sender); container.Width = this.Width; container.Height = ((frmSetu)sender).Height - btnGKD.Height - progress.Height - groupBox1.Height - 50; picSetu.Width = this.Width - 30; picSetu.Height = container.Height - 50; comStyle.SelectedIndex = 0; comSetuType.SelectedIndex = 1; picSetu.MouseWheel += new System.Windows.Forms.MouseEventHandler(this.picSetu_MouseWheel); // SyncCallBack(loadData()); //异步调取涩图 fh = new FuncHandle(this.loadData); AsyncCallback callback = new AsyncCallback(this.AsyncCallbackImpl); fh.BeginInvoke(callback, null); frmSetu_Resize(this, null); }
static void Download() { while (true) { Console.WriteLine("Download() try to download..."); string result; try { result = NetConnect.HttpGet(url, data); } catch (Exception e) { Console.WriteLine("Download() fail to get response..."); Thread.Sleep(Setting.downloadFailFrequent); continue; } //Console.WriteLine(result); //Console.ReadLine(); List <Photo> photos = JsonConvert.DeserializeObject <List <Photo> >(result); int i = 0; foreach (Photo photo in photos) { Console.WriteLine("Download() " + i++ + "\t" + photo.id + "\t Downloading..."); string path = Setting.picModeStr[Setting.picMode] + @"\" + photo.id + ".jpg"; string url; if (Setting.picMode == Setting.PICMODE_RAW) { url = photo.urls.raw; } else if (Setting.picMode == Setting.PICMODE_FULL) { url = photo.urls.full; } else if (Setting.picMode == Setting.PICMODE_REGULAR) { url = photo.urls.regular; } else if (Setting.picMode == Setting.PICMODE_SMALL) { url = photo.urls.small; } else { url = photo.urls.thumb; } mutex.WaitOne(); SimplePhoto r = PicStore.currentPhotos.Find( delegate(SimplePhoto simplePhoto) { return(simplePhoto.path.Equals(path)); }); mutex.ReleaseMutex(); if (r != null) { continue; } fh.BeginInvoke(url, path, callback, null); } Console.WriteLine("Download wait for next download..."); Thread.Sleep(Setting.downloadFrequent); } }