public LonLat GetCoordinatesFromServer(string ip, int port) { double[] arr; lock (syncLock) { /* critical code */ dataRequester.ChangeConnectionIfNeeded(ip, port); arr = dataRequester.RequestData(); } LonLat x = new LonLat(arr[0], arr[1]); return(x); }
private void Tick(Object source, ElapsedEventArgs e) { // Update timer counter if (timerCounter < timerLimit) { // Get location date and insert into data double[] locationData = requester.RequestData(); // DEBUG Debug.WriteLine(locationData[0].ToString() + "," + locationData[1].ToString() + ',' + timerCounter.ToString() + ',' + timerLimit.ToString()); // Save data if neccessary if (save) { data[timerCounter] = locationData; } // Notify tick listeners if (notifyTick) { foreach (Action <double[]> action in tickListeners) { action(locationData); } } ++timerCounter; } else { Debug.Write("Stopping timer."); // Reset timer / KILL TIMER timer = null; //timer.Stop(); timerCounter = 0; // Announce data is ready to take if (save) { dataReady = true; dataReadyTrigger.Set(); } // Notify done listeners if (notifyDone) { foreach (Action action in doneListeners) { action(); } } } }