viper
viper
CC#
Created by viper on 11/25/2023 in #help
C# noob, trying to do a GUI app with a background service
Hello, what I am trying to do is: - Have a background connection to KSP (game) through a RPC library. - Plot live data coming from the connection I've used the WPF template from Rider, as it is the first one to choose from. At the moment I am trying to figure out how to have this background thread that updates the graph (using ScottPlot) This main loop is here: https://github.com/viperML/KspAutopilot/blob/2ad64786e8dd1bdb6457bf0b4e278b40b76b191e/MainWindow.xaml.cs Right now it "works", but closing window crashes with:
Unhandled exception. System.Threading.Tasks.TaskCanceledException: A task was canceled.
at System.Windows.Threading.DispatcherOperation.Wait(TimeSpan timeout)
at System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherOperation operation, CancellationToken cancellationToken, TimeSpan timeout)
at System.Windows.Threading.Dispatcher.Invoke(Action callback, DispatcherPriority priority, CancellationToken cancellationToken, TimeSpan timeout)
at System.Windows.Threading.Dispatcher.Invoke(Action callback)
at KspAutopilot.MainWindow.Work(Object sender, EventArgs e) in C:\Users\ayats\Documents\KspAutopilot\MainWindow.xaml.cs:line 45
at System.Threading.Tasks.Task.<>c.<ThrowAsync>b__128_1(Object state)
at System.Threading.QueueUserWorkItemCallback.Execute()
at System.Threading.ThreadPoolWorkQueue.Dispatch()
at System.Threading.PortableThreadPool.WorkerThread.WorkerThreadStart()
Unhandled exception. System.Threading.Tasks.TaskCanceledException: A task was canceled.
at System.Windows.Threading.DispatcherOperation.Wait(TimeSpan timeout)
at System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherOperation operation, CancellationToken cancellationToken, TimeSpan timeout)
at System.Windows.Threading.Dispatcher.Invoke(Action callback, DispatcherPriority priority, CancellationToken cancellationToken, TimeSpan timeout)
at System.Windows.Threading.Dispatcher.Invoke(Action callback)
at KspAutopilot.MainWindow.Work(Object sender, EventArgs e) in C:\Users\ayats\Documents\KspAutopilot\MainWindow.xaml.cs:line 45
at System.Threading.Tasks.Task.<>c.<ThrowAsync>b__128_1(Object state)
at System.Threading.QueueUserWorkItemCallback.Execute()
at System.Threading.ThreadPoolWorkQueue.Dispatch()
at System.Threading.PortableThreadPool.WorkerThread.WorkerThreadStart()
Feel free to recommend any alternative to WPF or ScottPlot, as I just wanted to try the language as an alternative to python/matplotlib
129 replies