andyvorld / LGSTrayBattery

A tray app used to track battery levels of wireless Logitech mouse.
GNU General Public License v3.0
391 stars 33 forks source link

Cannot start second instance #32

Open Zenrage opened 2 years ago

Zenrage commented 2 years ago

Cannot start second instance of this application as I have multiple Logitech devices.

The exception is thrown when application tries to see what last device was used/found on startup. Create a new list when enumerating maybe (I tested this and got it to work on an older clone.

Zenrage commented 2 years ago

image

Zenrage commented 2 years ago

System.InvalidOperationException: Collection was modified; enumeration operation may not execute. at System.Collections.Generic.List1.Enumerator.MoveNextRare() at System.Collections.Generic.List1.Enumerator.MoveNext() at System.Linq.Enumerable.SelectManySingleSelectorIterator2.MoveNext() at System.Linq.Enumerable.TryGetFirst[TSource](IEnumerable1 source, Func2 predicate, Boolean& found) at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable1 source, Func2 predicate) at LGSTrayGUI.MainWindowViewModel.UpdateSelectedDeviceOnLaunch(Object sender, PropertyChangedEventArgs e) at LGSTrayGUI.MainWindowViewModel.<>c__DisplayClass26_01.b0(Object o, NotifyCollectionChangedEventArgs e) at System.Collections.ObjectModel.ObservableCollection1.OnCollectionChanged(NotifyCollectionChangedEventArgs e) at System.Collections.ObjectModel.ObservableCollection1.InsertItem(Int32 index, T item) at System.Collections.ObjectModel.Collection`1.Add(T item) at LGSTrayHID.HIDDeviceManager._deviceListener_DeviceInitialized(Object sender, DeviceEventArgs e) at System.Threading.Tasks.Task.<>c.b140_1(Object state) at System.Threading.QueueUserWorkItemCallback.<>c.<.cctor>b__6_0(QueueUserWorkItemCallback quwi) at System.Threading.ExecutionContext.RunForThreadPoolUnsafe[TState](ExecutionContext executionContext, Action`1 callback, TState& state) at System.Threading.QueueUserWorkItemCallback.Execute() at System.Threading.ThreadPoolWorkQueue.Dispatch() at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()