How to cancel all threads
I am adding a button in linqpad with an onclick action, like this
controls.Add(new Button("Customers", onClick: async btn => await StartClientAsync("Customers")));
when I click the button it runs fine and ends successfully but I get the message in Linqpad that I need to click CTRL-SHIFT F5 to cancel all threads.
I don't understand which thread is running, is there a way to stop all the threads in Code?
before I click the button there are no threads running.
I am using c# program , the main method is not async as I have no await.
thanks
Comments
Include the following code in your query:
This will kill the previous process each time you re-run the query.
I tried to add
Util.NewProcess = true
to all calls but could not get it to workMy code look something like this:
I'm not sure what the problem is. What are you trying to achieve?
my question is why LinqPad have threads running when the script has ended
Your script is technically still running since you're using Control components that need to function after the script has completed (e.g.,
Button
). To be able to run the component actions, something has to be running to execute them.If you want to run it and have it completely stop, don't use UI controls like you are, just run the action code directly.
yes ok, but the strange thing is that before I click the button the first time there are no threads running. so why do they need to be running the second time and not the first time?
I suspect the execution thread is spun up on first interaction. No need to run it if nothing needs to be run.