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); }
public static void AsyncCallbackImpl(IAsyncResult ar) { string path; try { path = fh.EndInvoke(ar); if (path == null) { Console.WriteLine("Callback() failed to download..."); return; } } catch (Exception e) { Console.WriteLine("Callback() failed to download..."); return; } Console.WriteLine(path + "\t Done..."); SimplePhoto item = new SimplePhoto(); item.path = path; mutex.WaitOne(); if (PicStore.currentPhotos.Count > Setting.iMaxPicNum) { PicStore.Remove(0); } PicStore.currentPhotos.Add(item); PicStore.Save(); mutex.ReleaseMutex(); }
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(); }
public void AsyncCallbackImpl(IAsyncResult ar) { string re = fh.EndInvoke(ar); MessageBox.Show(re + ar.AsyncState); }