Cancel Query - Doesn't actually Stop
Hi,
I've had this issue occur a number of times which is quite dangerous. Sometimes I go to run a query, and realize as it's beginning to run that I made a mistake in my code. So I hit the Cancel Query button, only to realize later that the code kept on running anyway. Not until I force close LINQPad.exe does the code actually stop.
As far as how I know this, I'm running code that makes API calls to a 3rd-party service, and I have Fiddler open. I can see after I stop the query, lots of requests still happening as though the code is still happily running for a long time after I cancelled it.
Is there some technical reason why the Cancel Query option doesn't actually cancel the query?
Thanks,
~ mellamokb
I've had this issue occur a number of times which is quite dangerous. Sometimes I go to run a query, and realize as it's beginning to run that I made a mistake in my code. So I hit the Cancel Query button, only to realize later that the code kept on running anyway. Not until I force close LINQPad.exe does the code actually stop.
As far as how I know this, I'm running code that makes API calls to a 3rd-party service, and I have Fiddler open. I can see after I stop the query, lots of requests still happening as though the code is still happily running for a long time after I cancelled it.
Is there some technical reason why the Cancel Query option doesn't actually cancel the query?
Thanks,
~ mellamokb
Comments
The cancel button stops the main thread, but any other threads created by the query may continue to run. You can stop all threads with the menu option "Cancel all threads and reset" (Shift+Control+F5). This will also recycle the application domain.
If your query is asynchronous and is kept alive by IObservable subscriptions, cancelling will merely dispose the subscriptions. In general, this should cleanly "end" the query. If it doesn't you can press Shift+Control+F5 to force an app domain recycle.
Is there a fix for this? There can be some nasty unexpected side effects.
http://www.linqpad.net/beta.aspx
Try that and let me know.