public override IAsyncResult BeginDisconnect(AsyncCallback callback) { this._delegateDisconnect = this.Disconnect; return this._delegateDisconnect.BeginInvoke(callback, null); }
/// <summary> /// 加载程序集 /// </summary> private void LoadAssembly() { try { string path = Path.GetFullPath(string.Format("{0}\\{1}", LibraryWrapper.ProcessorArchitecture, DllName)); _wrapper = new LibraryWrapper(path, "thostmduserapi.dll"); #region 读取方法入口列表 string resourceName = string.Format("CTPMarketApi.Entry{0}.txt", LibraryWrapper.IsAmd64 ? "64" : "32"); var assembly = System.Reflection.Assembly.GetExecutingAssembly(); Stream stream = assembly.GetManifestResourceStream(resourceName); if (stream != null) { using (StreamReader reader = new StreamReader(stream)) { string text = reader.ReadToEnd(); string entryStart = "ordinal hint"; int start = text.IndexOf(entryStart); if (start > -1) { string[] arr = text.Substring(start).Split('\n'); if (arr.Length > 1) { for (int i = 1; i < arr.Length; i++) { string[] list = arr[i].Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries); if (list.Length > 4) { _entryList.Add(list[3]); } } } } } stream.Close(); } if (_entryList.Count == 0) { throw new Exception(string.Format("Cannot find entry point form resource {0}", resourceName)); } #endregion #region 获取非托管方法 createSpi = GetDelegate <DelegateCreateSpi>("CreateSpi"); getApiVersion = GetDelegate <DelegateGetString>("GetApiVersion"); getTradingDay = GetDelegate <DelegatetTradingDay>("GetTradingDay"); connect = GetDelegate <DelegateConnect>("Connect"); disconnect = GetDelegate <DelegateDisconnect>("DisConnect"); userLogin = GetDelegate <DelegateUserLogin>("ReqUserLogin"); userLogout = GetDelegate <DelegateUserLogout>("ReqUserLogout"); subscribeMarketData = GetDelegate <DelegateSubscribeMarketData>("SubMarketData"); unsubscribeMarketData = GetDelegate <DelegateUnsubscribeMarketData>("UnSubscribeMarketData"); regOnRspError = GetDelegate <DelegateRegOnRspError>("RegOnRspError"); regOnHeartBeatWarning = GetDelegate <DelegateRegOnHeartBeatWarning>("RegOnHeartBeatWarning"); regOnFrontConnected = GetDelegate <DelegateRegOnFrontConnected>("RegOnFrontConnected"); regOnFrontDisconnected = GetDelegate <DelegateRegOnFrontDisconnected>("RegOnFrontDisconnected"); regOnRspUserLogin = GetDelegate <DelegateRegOnRspUserLogin>("RegOnRspUserLogin"); regOnRspUserLogout = GetDelegate <DelegateRegOnRspUserLogout>("RegOnRspUserLogout"); regOnRspSubMarketData = GetDelegate <DelegateRegOnRspSubMarketData>("RegOnRspSubMarketData"); regOnRspUnSubMarketData = GetDelegate <DelegateRegOnRspUnSubMarketData>("RegOnRspUnSubMarketData"); regOnRtnDepthMarketData = GetDelegate <DelegateRegOnRtnDepthMarketData>("RegOnRtnDepthMarketData"); #endregion _spi = createSpi(); } catch (Exception ex) { throw ex; } }