private void UpdateChartBackgroundWorker_DoWork(object sender, DoWorkEventArgs e) { int frequencyinmilliseconds = 5000; String[] information = new String[9]; while (true) { foreach (String currency in requestedcurrencies) { //There really should only be one string in requested currencies in //light of the whole only able to chose one currecny at a time from //the box list on the actual form so. while (((TrueFX.getinformationbatch() == /*null*/ Environment.NewLine) || (TrueFX.getinformationbatch() == null)) && (TrueFX.getpastmodestate() == false)) { } information = TrueFX.RequestCurrency(currency); //The zero thing should work for the commented reason above currencychart.Invoke(chartagentplotpoint, information, 0); } System.Threading.Thread.Sleep(frequencyinmilliseconds); //PROBLEM: Past mode will not work for the chart becuase their is no mechanism //to check for pastmode. So, it will not gather data for pastmode? But then again, //if pastmode is enabled, it should check right within the TrueFX Class. So I don't //know } }
private void UpdateCSVFileBackgroundWorker_DoWork(object sender, DoWorkEventArgs e) { int frequencyinmilliseconds = 5000; //In milliseconds while (true) { logdata(TrueFX.getinformationbatch()); System.Threading.Thread.Sleep(frequencyinmilliseconds); } }
private void UpdateCSVFileBackgroundWorker_DoWork(object sender, DoWorkEventArgs e) { // I REALLY HOPE I DESIGNATED A SEPERATE THREAD FOR THIS BECAUSE THIS COULD EXPLAIN OUR PROBLEM int frequencyinmilliseconds = 5000; //In milliseconds while (true) { logdata(TrueFX.getinformationbatch()); System.Threading.Thread.Sleep(frequencyinmilliseconds); } }
// This is method is linked to the UpdateChartBackgroundWorker.ASYNC( ) command in the beginning of the program, to start // the auto pilot of the update on the chart. private void UpdateChartBackgroundWorker_DoWork(object sender, DoWorkEventArgs e) { // It think I found the source of our mis sync. I set this thread to run in the background, and I even beleive // that I have a seperate thread for the graph as well. I gotta find a way for the two threads to communicate to // each other. I may try some event based programming for them to sync up. Because If I sync them at the // begin, anything can cause a delay in either one of them causing them to get thrown out of sync. So..., // it would be better for them to communicate to each other, so that way, they can constantly stay in-sync no // matter what happen during the RUNTIME of the program. ~ July 17th, 2017 OH THIS IS THE CHART WORKER!!! int frequencyinmilliseconds = 5000; String[] information = new String[9]; while (true) { if (UpdateChartBackgroundWorker.CancellationPending == true) { Console.WriteLine("WE RETURNED 1"); e.Cancel = true; return; } foreach (String currency in requestedcurrencies) { //There really should only be one string in requested currencies in //light of the whole only able to chose one currecny at a time from //the box list on the actual form so. while (((TrueFX.getinformationbatch() == /*null*/ Environment.NewLine) || (TrueFX.getinformationbatch() == null)) && (TrueFX.getpastmodestate() == false)) { } information = TrueFX.RequestCurrency(currency); //The zero thing should work for the commented reason above //Console.WriteLine("ENETERED THE THREAD"); // BUG SQUASHING COMMENT // The program doesn't enter the the loop if currency to be logged is checked. // That must mean requestedcurrencies is empty, when we check the currecncies to be logged check box. currencychart.Invoke(chartagentplotpoint, information, 0); } if (UpdateChartBackgroundWorker.CancellationPending == true) { Console.WriteLine("I RETURNED!"); e.Cancel = true; return; } System.Threading.Thread.Sleep(frequencyinmilliseconds); //PROBLEM: Past mode will not work for the chart becuase their is no mechanism //to check for pastmode. So, it will not gather data for pastmode? But then again, //if pastmode is enabled, it should check right within the TrueFX Class. So I don't //know } }
private void UpdateTableBackgroundWorker_DoWork(object sender, DoWorkEventArgs e) { //Equivalent to about 5 seconds int frequencyinmilliseconds = 5000; String[] information; String bidbigfigurestring; String bidpointsstring; String offerbigfigurestring; String offerpointsstring; String currency; String millisecondtimestamp; String high; String low; String open; while (true) { if (TrueFX.getpastmodestate() == true) { foreach (String currencyname in requestedcurrencies) { //This while loop is gonna be a problem for past mode //Because we dont exactly need the market to be open in order for //Past mode to be enabled, but here it does. Same thing for the //The UpdaetChart method below too. Have to fix that. //This logic will run for a bit, but it will crash eventually. You need to //add a method that will peek to see if there is any more data to log. while (((TrueFX.getinformationbatch() == /*null*/ Environment.NewLine) || (TrueFX.getinformationbatch() == null)) && (TrueFX.getpastmodestate() == false)) { } if (TrueFX.getpastmodestate() == false) { break; } information = TrueFX.RequestCurrency(currencyname); //currency = information[0].Remove(information[0].IndexOf('\n'), information[0].IndexOf('\n') + 1); currency = information[0]; millisecondtimestamp = information[1]; bidbigfigurestring = information[2]; bidpointsstring = information[3]; offerbigfigurestring = information[4]; offerpointsstring = information[5]; high = information[6]; low = information[7]; open = information[8]; table.Invoke(tableagentaddrow, currency, millisecondtimestamp, bidbigfigurestring + bidpointsstring, offerbigfigurestring + offerpointsstring, high, low, open); //This should still work because theoretically only //One currency is checked at a time still so //currencychart.Invoke(chartagentplotpoint, information, 0); } } //Whats happening is past mode is getting enabled in the middle of the else loop, //Forcing thre rest of the currencies to do the requested thing for all currencies //But you might not have the data for it. Ill have to fix this. else { foreach (String currencyname in ALLCURRENCIES) { //This while loop is gonna be a problem for past mode //Because we dont exactly need the market to be open in order for //Past mode to be enabled, but here it does. Same thing for the //The UpdaetChart method below too. Have to fix that. while (((TrueFX.getinformationbatch() == /*null*/ Environment.NewLine) || (TrueFX.getinformationbatch() == null)) && (TrueFX.getpastmodestate() == false)) { } if (TrueFX.getpastmodestate()) { break; } information = TrueFX.RequestCurrency(currencyname); //currency = information[0].Remove(information[0].IndexOf('\n'), information[0].IndexOf('\n') + 1); currency = information[0]; millisecondtimestamp = information[1]; bidbigfigurestring = information[2]; bidpointsstring = information[3]; offerbigfigurestring = information[4]; offerpointsstring = information[5]; high = information[6]; low = information[7]; open = information[8]; table.Invoke(tableagentaddrow, currency, millisecondtimestamp, bidbigfigurestring + bidpointsstring, offerbigfigurestring + offerpointsstring, high, low, open); //This should still work because theoretically only //One currency is checked at a time still so //currencychart.Invoke(chartagentplotpoint, information, 0); } } System.Threading.Thread.Sleep(frequencyinmilliseconds); //This method really isn't very visually pleasing //table.Invoke( tableagentclearrow ); } }
// This method is linked with the UpdateTableBackgroundWorker_DoWork private void UpdateTableBackgroundWorker_DoWork(object sender, DoWorkEventArgs e) { //Equivalent to about 5 seconds int frequencyinmilliseconds = 5000; String[] information; String bidbigfigurestring; String bidpointsstring; String offerbigfigurestring; String offerpointsstring; String currency; String millisecondtimestamp; String high; String low; String open; while (true) { // // // // // This is the past mode portion of the piece // // // // // This past mode isn't developed for the async if (TrueFX.getpastmodestate() == true) { foreach (String currencyname in requestedcurrencies) { //This while loop is gonna be a problem for past mode //Because we dont exactly need the market to be open in order for //Past mode to be enabled, but here it does. Same thing for the //The UpdaetChart method below too. Have to fix that. //This logic will run for a bit, but it will crash eventually. You need to //add a method that will peek to see if there is any more data to log. while (((TrueFX.getinformationbatch() == /*null*/ Environment.NewLine) || (TrueFX.getinformationbatch() == null)) && (TrueFX.getpastmodestate() == false)) { } if (TrueFX.getpastmodestate() == false) { break; } information = TrueFX.RequestCurrency(currencyname); //currency = information[0].Remove(information[0].IndexOf('\n'), information[0].IndexOf('\n') + 1); currency = information[0]; millisecondtimestamp = information[1]; bidbigfigurestring = information[2]; bidpointsstring = information[3]; offerbigfigurestring = information[4]; offerpointsstring = information[5]; high = information[6]; low = information[7]; open = information[8]; tabledata[currencyname] = information; table.Invoke(tableagentaddrow, currency, millisecondtimestamp, bidbigfigurestring + bidpointsstring, offerbigfigurestring + offerpointsstring, high, low, open); if (ChartTableSyncCheckBox.Checked == true) { if (UpdateChartBackgroundWorker.IsBusy == true) { UpdateChartBackgroundWorker.CancelAsync(); break; } else { foreach (String currencychecked in requestedcurrencies) { //There really should only be one string in requested currencies in //light of the whole only able to chose one currecny at a time from //the box list on the actual form so. // while (((TrueFX.getinformationbatch() == /*null*/ Environment.NewLine) || (TrueFX.getinformationbatch() == null)) && (TrueFX.getpastmodestate() == false)) { } information = tabledata[currencychecked]; //The zero thing should work for the commented reason above //Console.WriteLine("ENETERED THE THREAD"); // BUG SQUASHING COMMENT // The program doesn't enter the the loop if currency to be logged is checked. // That must mean requestedcurrencies is empty, when we check the currecncies to be logged check box. currencychart.Invoke(chartagentplotpoint, information, 0); } } } else { UpdateChartBackgroundWorker.RunWorkerAsync(); } //This should still work because theoretically only //One currency is checked at a time still so //currencychart.Invoke(chartagentplotpoint, information, 0); } } //Whats happening is past mode is getting enabled in the middle of the else loop, //Forcing thre rest of the currencies to do the requested thing for all currencies //But you might not have the data for it. Ill have to fix this. else { foreach (String currencyname in ALLCURRENCIES) { //This while loop is gonna be a problem for past mode //Because we dont exactly need the market to be open in order for //Past mode to be enabled, but here it does. Same thing for the //The UpdaetChart method below too. Have to fix that. while (((TrueFX.getinformationbatch() == /*null*/ Environment.NewLine) || (TrueFX.getinformationbatch() == null)) && (TrueFX.getpastmodestate() == false)) { } if (TrueFX.getpastmodestate()) { break; } information = TrueFX.RequestCurrency(currencyname); //currency = information[0].Remove(information[0].IndexOf('\n'), information[0].IndexOf('\n') + 1); currency = information[0]; millisecondtimestamp = information[1]; bidbigfigurestring = information[2]; bidpointsstring = information[3]; offerbigfigurestring = information[4]; offerpointsstring = information[5]; high = information[6]; low = information[7]; open = information[8]; tabledata[currencyname] = information; table.Invoke(tableagentaddrow, currency, millisecondtimestamp, bidbigfigurestring + bidpointsstring, offerbigfigurestring + offerpointsstring, high, low, open); //This should still work because theoretically only //One currency is checked at a time still so //currencychart.Invoke(chartagentplotpoint, information, 0); if (ChartTableSyncCheckBox.Checked == true) { if (UpdateChartBackgroundWorker.IsBusy == true) { Console.WriteLine("ITS CANCELING THE UPDATE BACKGROUND"); UpdateChartBackgroundWorker.CancelAsync(); break; } else { foreach (String currencychecked in requestedcurrencies) { //There really should only be one string in requested currencies in //light of the whole only able to chose one currecny at a time from //the box list on the actual form so. information = tabledata[currencychecked]; //The zero thing should work for the commented reason above //Console.WriteLine("ENETERED THE THREAD"); // BUG SQUASHING COMMENT // The program doesn't enter the the loop if currency to be logged is checked. // That must mean requestedcurrencies is empty, when we check the currecncies to be logged check box. if (UpdateChartBackgroundWorker.IsBusy) { Console.WriteLine("WHY IS IT BUSY?"); } currencychart.Invoke(chartagentplotpoint, information, 0); } } } else { // There are still errors here. I think whats happening is that we call for the cancellation of work, and we // don't wait for the updatechartbackgroundworker to return befor calling the run asynchronus method. Console.WriteLine("The extra special async cancel"); UpdateChartBackgroundWorker.CancelAsync(); while (UpdateChartBackgroundWorker.IsBusy) { } UpdateChartBackgroundWorker.RunWorkerAsync(); } } } System.Threading.Thread.Sleep(frequencyinmilliseconds); //This method really isn't very visually pleasing //table.Invoke( tableagentclearrow ); } }