delegate void SetCallback();//델리게이트를 이용해 쓰레드 에러 제거는 구글링을 해왔다 private void returned() { if (rtn) { if (this.InvokeRequired)//이부분은 구글링이다 { SetCallback d = new SetCallback(returned); this.Invoke(d, new object[] { }); } else { if (recv.Contains("null")) {//로그인 실패시 MessageBox.Show("로그인 실패\n다시 입력해주세요", "로그인 에러"); text_id.Text = ""; text_pw.Text = ""; reciever.Abort(); } else {//성공시 PCRoom frm = new PCRoom(this); id = text_id.Text; pw = text_pw.Text; frm.Show(); this.Hide(); reciever.Abort(); } } } }
// Используется вспомогательным потоком вычислений для отображения результатов: private void drawDir(Cell cl1, Cell cl2, float penWidth) { if ((Math.Abs(cl1.xIndex - cl2.xIndex) > 1) || (Math.Abs(cl1.yIndex - cl2.yIndex) > 1)) { return; } if (pictureBox1.InvokeRequired) { SetCallback d = new SetCallback(drawDir); this.Invoke(d, new object[] { cl1, cl2, penWidth }); } else { Graphics g = Graphics.FromImage(pictureBox1.Image); Pen pen = new Pen(Color.Red, penWidth); Point p1 = new Point(); Point p2 = new Point(); //pen.EndCap = System.Drawing.Drawing2D.LineCap.ArrowAnchor; p1.X = (CellSize + 1) * (cl1.xIndex - 1) + (int)((CellSize + 1) / 2); p1.Y = (CellSize + 1) * (cl1.yIndex - 1) + (int)((CellSize + 1) / 2); p2.X = (CellSize + 1) * (cl2.xIndex - 1) + (int)((CellSize + 1) / 2); p2.Y = (CellSize + 1) * (cl2.yIndex - 1) + (int)((CellSize + 1) / 2); g.DrawLine(pen, p1, p2); pen.Dispose(); g.Dispose(); pictureBox1.Invalidate(); } }
// Thread safe calls #region Threads private void TextTime() { // InvokeRequired required compares the thread ID of the // calling thread to the thread ID of the creating thread. // If these threads are different, it returns true. if (this.l_Timer.InvokeRequired) { SetCallback d = new SetCallback(TextTime); this.Invoke(d, new object[] { }); } else { if (ch_DLFinished.Checked) { UnitOfData dataType; // Depending on user's preference convert speed to bits or bytes if (SpeedDataType.SelectedIndex % 2 == 0) { timerText = ns.CurrentSpeedFromBits(out dataType) + " " + ns.GetUnitStringRepresentation(dataType); } else { timerText = ns.CurrentSpeedFromBytes(out dataType) + " " + ns.GetUnitStringRepresentation(dataType); } } else { timerText = st.Hours.ToString("00") + ":" + st.Minutes.ToString("00") + ":" + st.Seconds.ToString("00"); } l_Timer.Text = timerText; } }
// Second constructor public Modem(SerialPort prt, string prtnum, SetCallback c) { _call = c; _port = prt; _port.DataReceived += new SerialDataReceivedEventHandler(this.DataReceived); // _port.ReceivedBytesThreshold = 4; this.PortNumber = prtnum; this.PortBoudrate = this.DefaultBoudrate.ToString(); OpenModem(); }
/* Allows the timer thread to update the fifth news labels */ private void SetNews5(string Text) { if (this.LblNews[4].InvokeRequired) { SetCallback Callback = new SetCallback(SetNews5); this.Invoke(Callback, new object[] { Text }); } else { this.LblNews[4].Text = Text; } }
/* Allows the timer thread to update the condition label */ private void SetCondition(string Text) { if (this.LblWeather[2].InvokeRequired) { SetCallback Callback = new SetCallback(SetCondition); this.Invoke(Callback, new object[] { Text }); } else { this.LblWeather[2].Text = Text; } }
/* Allows the timer thread to update the time label */ private void SetTime(string Text) { if (this.LblDateTime[1].InvokeRequired) { SetCallback Callback = new SetCallback(SetTime); this.Invoke(Callback, new object[] { Text }); } else { this.LblDateTime[1].Text = Text; } }
public void btnStart_buttonUp() { if (this.btn_start.InvokeRequired) { SetCallback dp = new SetCallback(btnStart_buttonUp); this.Invoke(dp, new object[] { }); } else { btn_start.ButtonUp(); } }
/* Allows the timer thread to update the temperature label */ private void SetTemperature(string Text) { if (this.LblWeather[1].InvokeRequired) { SetCallback Callback = new SetCallback(SetTemperature); this.Invoke(Callback, new object[] { Text }); } else { this.LblWeather[1].Text = Text; } }
/// <summary> Closes the window. </summary> private void CloseWindow() { if (ui.textBox1.InvokeRequired) { SetCallback d = new SetCallback(CloseWindow); ui.Invoke(d, new object[] { }); } else { ui.Close(); } }
public void btnStop_buttonDown() { if (this.btn_stop.InvokeRequired) { SetCallback dp = new SetCallback(btnStop_buttonDown); this.Invoke(dp, new object[] { }); } else { btn_stop.ButtonDown(); } }
private void SetThreadSafe() { if (!CheckAccess()) { SetCallback d = new SetCallback(SetThreadSafe); Dispatcher.Invoke(d); } else { _eventList.Add(_event); } }
public void start(Startup sp, int i) { try { sp.checknetwork(i); } catch { if (sp.InvokeRequired) { SetCallback d = new SetCallback(start); this.Invoke(d, new object[] { sp, i }); } } }
private void Sort(List <int> list) { for (int i = 1; i < list.Count; i++) { int value = list[i]; int j = i - 1; while (j >= 0 && list[j] > value) { list[j + 1] = list[j]; SetCallback?.Invoke(j + 1, list[j]); j--; } list[j + 1] = value; SetCallback?.Invoke(j + 1, value); } }
private void SpeedDataTypeSelection() { // InvokeRequired required compares the thread ID of the // calling thread to the thread ID of the creating thread. // If these threads are different, it returns true. if (this.SpeedDataType.InvokeRequired) { SetCallback d = new SetCallback(SpeedDataTypeSelection); this.Invoke(d, new object[] { }); return; } else { activeDataUnitType = SpeedDataType.Text; unitOfDataIndex = SpeedDataType.SelectedIndex; } }
public void load(CleansingDisplay l, int change, string tablename) { { try { l.load(change, tablename); } catch { if (l.InvokeRequired) { SetCallback d = new SetCallback(load); l.Invoke(d, new object[] { l, change, tablename }); } } } }
private void SetText(string text, string text2) { try { if (this.encoderLabel.InvokeRequired) { SetCallback d = new SetCallback(SetText); this.Invoke(d, new object[] { text, text2 }); } else { this.encoderLabel.Text = text; this.encoderTime.Text = text2; } } catch { } }
// First constructor public Modem(SerialPort prt, SetCallback c) { _call = c; _port = prt; _port.DataReceived += new SerialDataReceivedEventHandler(this.DataReceived); // _port.ReceivedBytesThreshold = 4; if (_pname == "") { _pname = Modem.FirstAttachedModem().Port; } if (_boudrate == 0) { _boudrate = this.DefaultBoudrate; } // _port.Encoding = Encoding.UTF8; OpenModem(); }
private void SomeMethod() { Thread t = new Thread(() => { foreach (ListViewItem row in listView1.Items) { if (listView1.InvokeRequired) { SetCallback d = new SetCallback(SetText); this.Invoke(d, new object[] { row, "Checking" }); } Thread.Sleep(2000); } }); t.Start(); }
public void HandleStop(StopEventCause stopEventCause) { if (stopEventCause != StopEventCause.SoundFinishedPlaying) { return; } if (TracksList.InvokeRequired) { SetCallback d = HandleStop; BeginInvoke(d, stopEventCause); } else { // We continue to the next track SetTrackToPlay(CurrentTrack.NextTrack); } }
private void Merge(List <int> list, int left, int middle, int right) { List <int> leftList = list.GetRange(left, middle - left + 1); List <int> rightList = list.GetRange(middle + 1, right - middle); int listIndex = left; int leftIndex = 0; int rightIndex = 0; while (leftIndex < leftList.Count && rightIndex < rightList.Count) { if (leftList[leftIndex] <= rightList[rightIndex]) { list[listIndex] = leftList[leftIndex]; SetCallback?.Invoke(listIndex, leftList[leftIndex]); leftIndex++; } else { list[listIndex] = rightList[rightIndex]; SetCallback?.Invoke(listIndex, rightList[rightIndex]); rightIndex++; } listIndex++; } while (leftIndex < leftList.Count) { list[listIndex] = leftList[leftIndex]; SetCallback?.Invoke(listIndex, leftList[leftIndex]); leftIndex++; listIndex++; } while (rightIndex < rightList.Count) { list[listIndex] = rightList[rightIndex]; SetCallback?.Invoke(listIndex, rightList[rightIndex]); rightIndex++; listIndex++; } }
private void WarningLabel() { if (this.SpeedDataType.InvokeRequired) { SetCallback d = new SetCallback(WarningLabel); this.Invoke(d, new object[] { }); return; } else { if (networkInactive < 60) { l_Warning.Text = "Warning, network inactive\nSystem will shutdown in: " + networkInactive + " sec"; } if (clearWarning) { l_Warning.Text = ""; } } }
private void SetValue(Control control, params object[] obj) { if (control.InvokeRequired) { SetCallback d = new SetCallback(SetValue); this.Invoke(d, control, obj); } else { string name = control.Name; switch (name) { case "progressBar1": ((ProgressBar)control).Value = Convert.ToInt32(obj[0]); break; case "lbjd": ((Label)control).Text = obj[0].ToString(); ((Label)control).Refresh(); break; case "dataGridViewEx1": ((GWI.HIS.Windows.Controls.DataGridViewEx)dataGridViewEx1).DataSource = (DataTable)obj[0]; ((GWI.HIS.Windows.Controls.DataGridViewEx)dataGridViewEx1).Refresh(); break; case "btSearch": ((Button)control).Enabled = Convert.ToBoolean(obj[0]); break; case "btStop": ((Button)control).Enabled = Convert.ToBoolean(obj[0]); break; case "FrmHelpMatch": ((Form)control).Refresh(); ((Form)control).Activate(); break; } } }
private void SetRefreshMode(Boolean mode) { // InvokeRequired required compares the thread ID of the // calling thread to the thread ID of the creating thread. // If these threads are different, it returns true. if (refreshLabel.InvokeRequired) { SetCallback d = new SetCallback(SetRefreshMode); refreshLabel.Invoke(d, new object[] { mode }); } else { if (mode) { refreshLabel.Show(); } else { refreshLabel.Hide(); } } }
public void loadProcessing(Processing l, bool flag) { if (flag == true) { l.ShowDialog(); } else { try { l.Close(); } catch { if (l.InvokeRequired) { SetCallback d = new SetCallback(loadProcessing); this.Invoke(d, new object[] { l, false }); } } } }
/// <summary> /// pass in 0 if you want the logged in user or the default of 100 messages /// </summary> /// <returns>This method returns true on success, false on failure, or an error code.</returns> private bool Set(long uid, string status, bool isAsync, SetCallback callback, Object state) { var parameterList = new Dictionary <string, string> { { "method", "facebook.status.set" } }; Utilities.AddOptionalParameter(parameterList, "uid", uid); Utilities.AddOptionalParameter(parameterList, "status", status); if (isAsync) { SendRequestAsync <status_set_response, bool>(parameterList, !string.IsNullOrEmpty(Session.SessionKey), new FacebookCallCompleted <bool>(callback), state); return(true); } #if !SILVERLIGHT var response = SendRequest <status_set_response>(parameterList, !string.IsNullOrEmpty(Session.SessionKey)); #else var response = SendRequest <status_set_response>(parameterList, !string.IsNullOrEmpty(Session.SessionKey)); #endif return(response == null ? true : response.TypedValue); }
private void SetValue(object progress) { if (progressBar.InvokeRequired) { SetCallback d = new SetCallback(SetValue); this.Invoke(d, new object[] { progress }); } else { progressBar.Value = (int)progress; } }
/// <summary> /// Updates a user's Facebook status through your application. This is a streamlined version of users.setStatus. /// </summary> /// <example> /// <code> /// private static void RunDemoAsync() /// { /// Api api = new Api(new DesktopSession(Constants.ApplicationKey, Constants.ApplicationSecret, Constants.ApplicationSecret, Constants.SessionKey)); /// api.Status.SetAsync("Setting a test async status.", AsyncDemoCompleted, null); /// } /// /// private static void AsyncDemoCompleted(bool result, Object state, FacebookException e) /// { /// var actual = result; /// } /// </code> /// </example> /// <param name="status">The status message to set. Note: The maximum message length is 255 characters; messages longer than that limit will be truncated and appended with '...'.</param> /// <param name="callback">The AsyncCallback delegate</param> /// <param name="state">An object containing state information for this asynchronous request</param> /// <returns>This method returns true on success, false on failure, or an error code.</returns> /// <remarks>Pass in 0 if you want the logged in user or the default of 100 messages</remarks> public void SetAsync(string status, SetCallback callback, Object state) { SetAsync(0, status, callback, state); }
private void SetMDErrorRspInfo(object s) { if (this.InvokeRequired) { SetCallback d = new SetCallback(SetMDErrorRspInfo); this.BeginInvoke(d, new object[] { s }); } else { ThostFtdcRspInfoField pRspInfo = (ThostFtdcRspInfoField)s; switch (pRspInfo.ErrorID) { case 1: break; default: MessageBox.Show("收到错误,错误ID=" + pRspInfo.ErrorID.ToString() + "\n错误描述:" + pRspInfo.ErrorMsg); break; } } }
/// <summary> /// 行情接口->获取深度行情 /// </summary> /// <param name="s">行情结构体,需强转</param> private void SetMDDepthMarketData(object s) { if (this.InvokeRequired) { SetCallback d = new SetCallback(SetMDDepthMarketData); this.BeginInvoke(d, new object[] { s }); } else { ThostFtdcDepthMarketDataField pDepthMarketData = (ThostFtdcDepthMarketDataField)s; QueueSendData sQueueSend = new QueueSendData(); sQueueSend.QueueType = EnumQueueType.DepthMarketData; sQueueSend.QueueData = s; List_QueueSend.Add(sQueueSend); SignMainQueueSend.Set(); DataRow DR_Find = this.DT_DeepInstrumentRSP.Rows.Find(pDepthMarketData.InstrumentID); DataRow dr = this.DT_DeepInstrumentRSP.NewRow(); #region 实时行情更新赋值 dr["叫买价"] = (pDepthMarketData.BidPrice1 != Double.MaxValue) ? Function.GetRoundNum(pDepthMarketData.BidPrice1, 2).ToString() : null; dr["叫买价2"] = (pDepthMarketData.BidPrice2 != Double.MaxValue) ? Function.GetRoundNum(pDepthMarketData.BidPrice2, 2).ToString() : null; dr["叫买价3"] = (pDepthMarketData.BidPrice3 != Double.MaxValue) ? Function.GetRoundNum(pDepthMarketData.BidPrice3, 2).ToString() : null; dr["叫买价4"] = (pDepthMarketData.BidPrice4 != Double.MaxValue) ? Function.GetRoundNum(pDepthMarketData.BidPrice4, 2).ToString() : null; dr["叫买价5"] = (pDepthMarketData.BidPrice5 != Double.MaxValue) ? Function.GetRoundNum(pDepthMarketData.BidPrice5, 2).ToString() : null; dr["叫买量"] = pDepthMarketData.BidVolume1.ToString(); dr["叫买量2"] = pDepthMarketData.BidVolume2.ToString(); dr["叫买量3"] = pDepthMarketData.BidVolume3.ToString(); dr["叫买量4"] = pDepthMarketData.BidVolume4.ToString(); dr["叫买量5"] = pDepthMarketData.BidVolume5.ToString(); dr["当日均价"] = (pDepthMarketData.AveragePrice != Double.MaxValue) ? Function.GetRoundNum(pDepthMarketData.AveragePrice, 2).ToString() : null; dr["叫卖价"] = (pDepthMarketData.AskPrice1 != Double.MaxValue) ? Function.GetRoundNum(pDepthMarketData.AskPrice1, 2).ToString() : null; dr["叫卖价2"] = (pDepthMarketData.AskPrice2 != Double.MaxValue) ? Function.GetRoundNum(pDepthMarketData.AskPrice2, 2).ToString() : null; dr["叫卖价3"] = (pDepthMarketData.AskPrice3 != Double.MaxValue) ? Function.GetRoundNum(pDepthMarketData.AskPrice3, 2).ToString() : null; dr["叫卖价4"] = (pDepthMarketData.AskPrice4 != Double.MaxValue) ? Function.GetRoundNum(pDepthMarketData.AskPrice4, 2).ToString() : null; dr["叫卖价5"] = (pDepthMarketData.AskPrice5 != Double.MaxValue) ? Function.GetRoundNum(pDepthMarketData.AskPrice5, 2).ToString() : null; dr["叫卖量"] = pDepthMarketData.AskVolume1.ToString(); dr["叫卖量2"] = pDepthMarketData.AskVolume2.ToString(); dr["叫卖量3"] = pDepthMarketData.AskVolume3.ToString(); dr["叫卖量4"] = pDepthMarketData.AskVolume4.ToString(); dr["叫卖量5"] = pDepthMarketData.AskVolume5.ToString(); dr["收盘价"] = (pDepthMarketData.ClosePrice != Double.MaxValue) ? Function.GetRoundNum(pDepthMarketData.ClosePrice, 2).ToString() : null; dr["虚实度"] = (pDepthMarketData.CurrDelta != Double.MaxValue) ? Function.GetRoundNum(pDepthMarketData.CurrDelta, 2).ToString() : null; dr["最高价"] = (pDepthMarketData.HighestPrice != Double.MaxValue) ? Function.GetRoundNum(pDepthMarketData.HighestPrice, 2).ToString() : null; dr["最新价"] = (pDepthMarketData.LastPrice != Double.MaxValue) ? Function.GetRoundNum(pDepthMarketData.LastPrice, 2).ToString() : null; dr["跌停板价"] = (pDepthMarketData.LowerLimitPrice != Double.MaxValue) ? Function.GetRoundNum(pDepthMarketData.LowerLimitPrice, 2).ToString() : null; dr["最低价"] = (pDepthMarketData.LowestPrice != Double.MaxValue) ? Function.GetRoundNum(pDepthMarketData.LowestPrice, 2).ToString() : null; dr["持仓量"] = (pDepthMarketData.OpenInterest != Double.MaxValue) ? Function.GetRoundNum(pDepthMarketData.OpenInterest, 2).ToString() : null; dr["开盘价"] = (pDepthMarketData.OpenPrice != Double.MaxValue) ? Function.GetRoundNum(pDepthMarketData.OpenPrice, 2).ToString() : null; dr["昨收盘"] = (pDepthMarketData.PreClosePrice != Double.MaxValue) ? Function.GetRoundNum(pDepthMarketData.PreClosePrice, 2).ToString() : null; dr["昨虚实度"] = (pDepthMarketData.PreDelta != Double.MaxValue) ? Function.GetRoundNum(pDepthMarketData.PreDelta, 2).ToString() : null; dr["昨持仓"] = (pDepthMarketData.PreOpenInterest != Double.MaxValue) ? Function.GetRoundNum(pDepthMarketData.PreOpenInterest, 2).ToString() : null; dr["上次结算价"] = (pDepthMarketData.PreSettlementPrice != Double.MaxValue) ? Function.GetRoundNum(pDepthMarketData.PreSettlementPrice, 2).ToString() : null; dr["结算价"] = (pDepthMarketData.SettlementPrice != Double.MaxValue) ? Function.GetRoundNum(pDepthMarketData.SettlementPrice, 2).ToString() : null; dr["成交金额"] = (pDepthMarketData.Turnover != Double.MaxValue) ? Function.GetRoundNum(pDepthMarketData.Turnover, 2).ToString() : null; dr["毫秒"] = pDepthMarketData.UpdateMillisec.ToString(); dr["时间"] = pDepthMarketData.UpdateTime.ToString(); dr["涨停板价"] = (pDepthMarketData.UpperLimitPrice != Double.MaxValue) ? Function.GetRoundNum(pDepthMarketData.UpperLimitPrice, 2).ToString() : null; dr["数量"] = pDepthMarketData.Volume.ToString(); dr["交易日"] = pDepthMarketData.TradingDay.ToString(); dr["品种名称"] = pDepthMarketData.InstrumentID; dr["自然日"] = pDepthMarketData.ActionDay.ToString(); #endregion if (DR_Find != null) { DR_Find.ItemArray = dr.ItemArray; } else { this.DT_DeepInstrumentRSP.Rows.Add(dr); } } }
/// <summary> /// 交易接口->获取所有正在交易的合约 /// </summary> /// <param name="s"></param> private void SetTDRspQryInstrument(object s) { if (this.InvokeRequired) { SetCallback d = new SetCallback(SetTDRspQryInstrument); this.BeginInvoke(d, new object[] { s }); } else { ThostFtdcInstrumentField pInstrument = (ThostFtdcInstrumentField)s; DataRow dr = this.DT_Instrument.Rows.Find(pInstrument.InstrumentID); if (dr == null) { dr = this.DT_Instrument.NewRow(); dr["品种名称"] = pInstrument.InstrumentID; dr[1] = pInstrument.ProductID; dr[2] = pInstrument.InstrumentName; dr[3] = pInstrument.ExchangeID; this.DT_Instrument.Rows.Add(dr); } if (!this.comboBox_ProductID.Items.Contains(pInstrument.ProductID)) { this.comboBox_ProductID.Items.Add(pInstrument.ProductID); } } }
private void SetTDErrorRspInfo(object s) { if (this.InvokeRequired) { SetCallback d = new SetCallback(SetTDErrorRspInfo); this.BeginInvoke(d, new object[] { s }); } else { ThostFtdcRspInfoField pRspInfo = (ThostFtdcRspInfoField)s; switch (pRspInfo.ErrorID) { case 42: var Result = MessageBox.Show("投资结果未确认,是否立即确认?", "报单错误!", MessageBoxButtons.YesNo, MessageBoxIcon.Error); if (Result == DialogResult.Yes) { //todo 确认投资者结算 this.TDReqSettlementInfoConfirm(); } break; default: MessageBox.Show("收到错误,错误ID=" + pRspInfo.ErrorID.ToString() + "\n错误描述:" + pRspInfo.ErrorMsg); break; } } }
private void plotPoints() { if (this.chartSWR.InvokeRequired) { SetCallback d = new SetCallback(plotPoints); this.Invoke(d); } else { listBoxResults.Items.Clear(); foreach(string s in strlist) { string[] s1 = s.Split(','); if (s1.Count() > 1) { listBoxResults.Items.Add( Math.Round(double.Parse(s1[0]) / 1000000,6).ToString("0.000000") + "," + Math.Round(double.Parse(s1[1]) / 1000,6).ToString("0.0000")); } } //listBox1.Items.AddRange(strlist.ToArray()); chartSWR.ChartAreas["ChartArea1"].AxisY.Maximum = 10; foreach (ResponseClass l in list) { chartSWR.Series["VSWR"].Points.AddXY(l.Freq, l.VSWR); } chartSWR.Series["VSWR"].ChartArea = "ChartArea1"; btnSweep.Enabled = true; btnSaveCSV.Enabled = true; btnSweep.Text = "Sweep"; } }
private void SetTitle(object value) { if (this.InvokeRequired) { SetCallback d = new SetCallback(SetTitle); this.Invoke(d, new object[]{value}); } else { this.Text = (string)value; } }
/// <summary> /// pass in 0 if you want the logged in user or the default of 100 messages /// </summary> /// <returns>This method returns true on success, false on failure, or an error code.</returns> private bool Set(long uid, string status, bool isAsync, SetCallback callback, Object state) { var parameterList = new Dictionary<string, string> { { "method", "facebook.status.set" } }; Utilities.AddOptionalParameter(parameterList, "uid", uid); Utilities.AddOptionalParameter(parameterList, "status", status); if (isAsync) { SendRequestAsync<status_set_response, bool>(parameterList, !string.IsNullOrEmpty(Session.SessionKey), new FacebookCallCompleted<bool>(callback), state); return true; } #if !SILVERLIGHT var response = SendRequest<status_set_response>(parameterList, !string.IsNullOrEmpty(Session.SessionKey)); #else var response = SendRequest<status_set_response>(parameterList, !string.IsNullOrEmpty(Session.SessionKey)); #endif return response == null ? true : response.TypedValue; }
/// <summary> /// 交易接口->获得报单回馈信息 /// </summary> /// <param name="s"></param> private void SetTDOnRtnOrder(object s) { if (this.InvokeRequired) { SetCallback d = new SetCallback(SetTDOnRtnOrder); this.BeginInvoke(d, new object[] { s }); } else { ThostFtdcOrderField pOrder = (ThostFtdcOrderField)s; object[] objs = new object[] { pOrder.OrderRef, pOrder.SessionID, pOrder.FrontID }; DataRow DR_Find = this.DT_RtnOrder.Rows.Find(objs); DataRow dr = this.DT_RtnOrder.NewRow(); #region 报单回馈赋值更新 //{ "报单引用", "会话标识", "前置机标识", "报单编号","交易所","品种名称", "买卖", "开平", "投机标志", "价格", "报单量", "今成交", "剩余量", "报单日期", "报单时间", "报单状态", "状态信息", "备注" }; dr["报单引用"] = pOrder.OrderRef.ToString(); dr["会话标识"] = pOrder.SessionID.ToString(); dr["前置机标识"] = pOrder.FrontID.ToString(); dr["报单编号"] = pOrder.OrderSysID.ToString(); dr["品种名称"] = pOrder.InstrumentID.ToString(); dr["交易所"] = pOrder.ExchangeID.ToString(); dr["买卖"] = (pOrder.Direction == EnumDirectionType.Buy) ? "买 " : " 卖"; switch (pOrder.CombOffsetFlag) { case EnumOffsetFlagType.Close: case EnumOffsetFlagType.CloseToday: case EnumOffsetFlagType.CloseYesterday: dr["开平"] = " 平"; break; case EnumOffsetFlagType.Open: dr["开平"] = "开"; break; default: dr["开平"] = pOrder.CombOffsetFlag.ToString(); break; } switch (pOrder.CombHedgeFlag) { case EnumHedgeFlagType.Speculation: dr["投机标志"] = "投机"; break; case EnumHedgeFlagType.Arbitrage: dr["投机标志"] = "套利"; break; case EnumHedgeFlagType.Hedge: dr["投机标志"] = "套保"; break; default: dr["投机标志"] = pOrder.CombHedgeFlag.ToString(); break; } dr["价格"] = pOrder.LimitPrice.ToString(); dr["报单量"] = pOrder.VolumeTotalOriginal.ToString(); dr["今成交"] = pOrder.VolumeTraded.ToString(); dr["剩余量"] = pOrder.VolumeTotal.ToString(); dr["报单日期"] = pOrder.InsertDate.ToString(); dr["报单时间"] = pOrder.InsertTime.ToString(); dr["报单状态"] = pOrder.OrderStatus.ToString(); dr["状态信息"] = pOrder.StatusMsg.ToString(); if (pOrder.SessionID != this.iSessionID || pOrder.FrontID != this.iFrontID) { dr["备注"] = "非本机发单"; } else { dr["备注"] = "本机发单"; } #endregion if (DR_Find != null) { DR_Find.ItemArray = dr.ItemArray; } else { this.DT_RtnOrder.Rows.Add(dr); } } }
private void SetDescription(object value) { if (label.InvokeRequired) { SetCallback d = new SetCallback(SetDescription); this.Invoke(d, new object[]{value}); } else { label.Text = (string)value; } }
/// <summary> /// 交易接口->修改交易连接状态 /// </summary> /// <param name="s"></param> private void SetTDConnState(object s) { if (this.InvokeRequired) { SetCallback d = new SetCallback(SetTDConnState); this.BeginInvoke(d, new object[] { s }); } else { this.TSS_TDConnState.Text = (string)s; } }
/// <summary> /// 交易接口->修改持仓 /// </summary> /// <param name="s"></param> private void SetTDRspQryInvestorPosition(object s) { if (this.InvokeRequired) { SetCallback d = new SetCallback(SetTDRspQryInvestorPosition); this.BeginInvoke(d, new object[] { s }); } else { ThostFtdcInvestorPositionField pInvestorPositionDetail = (ThostFtdcInvestorPositionField)s; DataRow dr = this.DT_InvestorPositionDetail.NewRow(); dr["合约代码"] = pInvestorPositionDetail.InstrumentID; dr["投机标志"] = pInvestorPositionDetail.HedgeFlag; dr["结算价"] = pInvestorPositionDetail.SettlementPrice; dr["平仓量"] = pInvestorPositionDetail.CloseVolume; dr["平仓金额"] = pInvestorPositionDetail.CloseAmount; } }
/// <summary> /// Updates a user's Facebook status through your application. This is a streamlined version of users.setStatus. /// </summary> /// <example> /// <code> /// private static void RunDemoAsync() /// { /// Api api = new Api(new DesktopSession(Constants.ApplicationKey, Constants.ApplicationSecret, Constants.ApplicationSecret, Constants.SessionKey)); /// api.Status.SetAsync(Constants.UserId, "Setting a test async status.", AsyncDemoCompleted, null); /// } /// /// private static void AsyncDemoCompleted(bool result, Object state, FacebookException e) /// { /// var actual = result; /// } /// </code> /// </example> /// <param name="uid">The user ID of the user whose status you are setting. Note: This parameter applies only to Web applications. Facebook ignores this parameter if it is passed by a desktop application.</param> /// <param name="status">The status message to set. Note: The maximum message length is 255 characters; messages longer than that limit will be truncated and appended with '...'.</param> /// <param name="callback">The AsyncCallback delegate</param> /// <param name="state">An object containing state information for this asynchronous request</param> /// <returns>This method returns true on success, false on failure, or an error code.</returns> /// <remarks>Pass in 0 if you want the logged in user or the default of 100 messages</remarks> public void SetAsync(long uid, string status, SetCallback callback, Object state) { Set(uid, status, true, callback, state); }
/// <summary> /// Callback called when console is showen. /// </summary> public void SetConsoleShown() { if (trayMenu.InvokeRequired) { SetCallback callback = new SetCallback(SetConsoleShown); this.Invoke(callback); } else { miShowConsole.Visible = false; miHideConsole.Visible = true; } }
/// <summary> /// Callback called when server is powered off. /// </summary> public void SetServerPoweredOff() { trayIcon.Icon = iconStop; if (trayMenu.InvokeRequired) { SetCallback callback = new SetCallback(SetServerPoweredOff); this.Invoke(callback); } else { miShowConsole.Visible = false; miHideConsole.Visible = false; miStartServer.Visible = true; miStopServer.Visible = false; miRestartServer.Visible = false; miPingServer.Visible = false; } }
/// <summary> /// Callback called when server is started. /// </summary> public void SetServerRunning() { trayIcon.Icon = iconRun; if (trayMenu.InvokeRequired) { SetCallback callback = new SetCallback(SetServerRunning); this.Invoke(callback); } else { miStartServer.Visible = false; miStopServer.Visible = true; miRestartServer.Visible = true; miPingServer.Visible = true; } }
/// <summary> /// Set removing is stopped. /// </summary> public void Stop() { if (pbWorking.InvokeRequired) { try { SetCallback callback = new SetCallback(Stop); Invoke(callback); } catch { } } else { pbWorking.Visible = false; btnCancel.Visible = false; chkBackup.Enabled = true; rbRemoveBOM.Enabled = true; rbTestBOM.Enabled = true; btnClearList.Enabled = true; rbListBOMFiles.Enabled = true; rbListAllFiles.Enabled = true; txtExtension.Enabled = true; removeBOM = null; } }
/// <summary> /// 交易接口->成交通知 /// </summary> /// <param name="s"></param> private void SetTDOnRtnTrade(object s) { if (this.InvokeRequired) { SetCallback d = new SetCallback(SetTDOnRtnTrade); this.BeginInvoke(d, new object[] { s }); } else { DT_InvestorPositionDetail.Clear(); this.TDReqQryInvestorPositionDetail(false); GridView_InvestorPositionDetail.DataSource = DT_InvestorPositionDetail; } }
private void SetMin(object value) { if (progressBar.InvokeRequired) { SetCallback d = new SetCallback(SetMin); this.Invoke(d, new object[] { value }); } else { progressBar.Minimum = (int)value; } }
/// <summary> /// 交易接口->修改持仓明细 /// </summary> /// <param name="s"></param> private void SetTDRspQryInvestorPositionDetail(object s) { if (this.InvokeRequired) { SetCallback d = new SetCallback(SetTDRspQryInvestorPositionDetail); this.BeginInvoke(d, new object[] { s }); } else { ThostFtdcInvestorPositionDetailField pInvestorPositionDetail = (ThostFtdcInvestorPositionDetailField)s; DataRow dr = this.DT_InvestorPositionDetail.NewRow(); if (pInvestorPositionDetail.OpenDate != pInvestorPositionDetail.TradingDay) { dr["持仓类型"] = "昨仓"; } else { dr["持仓类型"] = "今仓"; } dr["合约代码"] = pInvestorPositionDetail.InstrumentID; dr["开仓日期"] = pInvestorPositionDetail.OpenDate; dr["买卖"] = (pInvestorPositionDetail.Direction == EnumDirectionType.Buy) ? "买 " : " 卖"; switch (pInvestorPositionDetail.HedgeFlag) { case EnumHedgeFlagType.Speculation: dr["投机标志"] = "投机"; break; case EnumHedgeFlagType.Arbitrage: dr["投机标志"] = "套利"; break; case EnumHedgeFlagType.Hedge: dr["投机标志"] = "套保"; break; default: dr["投机标志"] = pInvestorPositionDetail.HedgeFlag.ToString(); break; } dr["成交编号"] = pInvestorPositionDetail.TradeID; dr["数量"] = pInvestorPositionDetail.Volume; dr["开仓价"] = pInvestorPositionDetail.OpenPrice; dr["交易日"] = pInvestorPositionDetail.TradingDay; dr["结算编号"] = pInvestorPositionDetail.SettlementID; switch (pInvestorPositionDetail.TradeType) { case EnumTradeTypeType.Common: dr["成交类型"] = "普通成交"; break; case EnumTradeTypeType.OptionsExecution: dr["成交类型"] = "期权执行"; break; case EnumTradeTypeType.OTC: dr["成交类型"] = "OTC成交"; break; case EnumTradeTypeType.EFPDerived: dr["成交类型"] = "期转现成交"; break; case EnumTradeTypeType.CombinationDerived: dr["成交类型"] = "组合成交"; break; default: dr["成交类型"] = pInvestorPositionDetail.TradeType; break; } dr["昨结算价"] = pInvestorPositionDetail.LastSettlementPrice; dr["结算价"] = pInvestorPositionDetail.SettlementPrice; dr["平仓量"] = pInvestorPositionDetail.CloseVolume; dr["平仓金额"] = pInvestorPositionDetail.CloseAmount; this.DT_InvestorPositionDetail.Rows.Add(dr); } }
private void SetProgressBarStyle(object value) { if (progressBar.InvokeRequired) { SetCallback d = new SetCallback(SetProgressBarStyle); this.Invoke(d, new object[]{value}); } else { progressBar.Style = (ProgressBarStyle)value; } }