using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using TradeIdeas.ServerConnection; using TradeIdeas.MarketDataProxy.DataFormats; using System.Threading; using System.Diagnostics; namespace MarketDataProxy { public partial class QueueStatusForm : Form { public QueueStatusForm() { InitializeComponent(); timer1.Enabled = true; } // for the CPU monitor.. private static PerformanceCounter cpuCounter = new PerformanceCounter(); //Code Snippet Inspired from Phil's ConnectionListenerForm///// private static QueueStatusForm _instance; private static Object _instanceLock = new Object(); public static QueueStatusForm GetInstance() { // We could allow more than one of these, but that's not the intent. lock (_instanceLock) { // http://www.yoda.arachsys.com/csharp/singleton.html if (_instance == null) _instance = new QueueStatusForm(); return _instance; } } //End of Code Snippet Inspired from Phil's ConnectionListenerForm///// // Object stateInfo protected void timer1_Tick(object sender, System.EventArgs e) { //Set our CPU Usage parameters cpuCounter.CategoryName = "Processor"; cpuCounter.CounterName = "% Processor Time"; cpuCounter.InstanceName = "_Total"; //Here is the timed event...Please remember, when you //"install" a timer to your winForm, PLEASE go to the //properties for the timer(TICK) and select timer1_tick //from the dropdown box (or whatever you've named that // timer object) OTHERWISE YOUR TIMER WONT WORK IN YOUR //CODE -RESULTING IN A LOT OF WASTED TIME!!!! //here's where stuff will be updated on the WindowsForm TradeIdeas.MarketDataProxy.SymbolListenerThread.Status testInfo = new TradeIdeas.MarketDataProxy.SymbolListenerThread.Status(); try { //Using the Globals beats using delegates for data transfer... testInfo = TradeIdeas.MarketDataProxy.Globals.symbolListenerThread.GetStatus(); } catch (NullReferenceException) { timer1.Stop(); } txtTotalMsg.Text = testInfo.totalMessages.ToString(); txtSubscriptionQueue.Text = testInfo.subscriptionQueueSize.ToString(); txtNewData.Text = testInfo.dataProviderQueueSize.ToString(); txtClose.Text = testInfo.disconnectQueueSize.ToString(); txtTotSymbol.Text = testInfo.totalSymbols.ToString(); txtRctSymbol.Text = testInfo.recentSymbols.ToString(); txtRctMess.Text = testInfo.recentMessages.ToString(); txtRctItvl.Text = testInfo.recentInterval.ToString(); txtConnChk.Text = TradeIdeas.MarketDataProxy.Globals.TeletraderConnectionCheckCounter.ToString(); txtSndFunction.Text = TradeIdeas.MarketDataProxy.Globals.sendFunctionCounter.ToString(); txtSendAll.Text = TradeIdeas.MarketDataProxy.Globals.sendAllCounter.ToString(); txtCPU.Text = cpuCounter.NextValue().ToString(); } private void btnClose_Click(object sender, EventArgs e) { this.Hide(); } private void ConnectionListenerForm_FormClosing(object sender, FormClosingEventArgs e) { if (e.CloseReason == CloseReason.None) { e.Cancel = true; Hide(); } } } }