private void OrderBookForm_FormClosing(object sender, FormClosingEventArgs e) { Console.WriteLine("OrderBookForm_FormClosing"); PriceObserver.Get().UnOnserve(ReceivePrice); EventReceiver.Instance.OrderBookUpdatedEvent -= OnOrderBookUpdated; Setting.Instance.Save(); if (connection != null) { connection.Close(); connection = null; } if (tcpClient != null) { tcpClient.Close(); tcpClient = null; } if (retriveVolumeQueue != null) { retriveVolumeQueue.Add(null); // retriveVolumeQueue = null; } /* if(oandaApi != null) { * oandaApi.Dispose(); * oandaApi = null; * }*/ if (retriveVolumesThread != null) { retriveVolumesThread.Interrupt(); retriveVolumesThread = null; } }
public static PriceObserver Get(string instrument = "USD_JPY,EUR_JPY,EUR_USD") { lock (typeof(PriceObserver)) { if (!instances.ContainsKey(instrument)) { instances[instrument] = new PriceObserver(instrument); } return(instances[instrument]); } }
private void OrderBookForm_Load(object sender, EventArgs ev) { connection = DBUtils.OpenConnection(); comboBox1.SelectedIndex = 0; // LoadOrderBookList(INSTRUMENTS[0]); /* splitContainer1.Panel2.HorizontalScroll.Value = splitContainer1.Panel1.HorizontalScroll.Value * = (splitContainer1.Panel1.HorizontalScroll.Maximum + splitContainer1.Panel1.HorizontalScroll.Minimum - splitContainer1.Panel1.ClientSize.Width) / 2;*/ EventReceiver.Instance.OrderBookUpdatedEvent += OnOrderBookUpdated; retriveVolumesThread = new Thread(new ThreadStart(RetriveVolumes)); retriveVolumesThread.Start(); PriceObserver.Get().Observe(ReceivePrice); }