private void StopTracking(object sender, RoutedEventArgs e) { ModulesManager.TrackerDisable(); List <WalkerStatement> trackedList = ModulesManager.tracker.list; while (!ModulesManager.tracker.stopped) { ; //waiting for tracker finished } ModulesManager.tracker.list = new List <WalkerStatement>(); Way way = new Way(trackedList); insertToList(way); fillList(); listBox.SelectedItem = way; startButton.Visibility = Visibility.Visible; }