Home

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

Comments

  • When you cancel such a query, does LINQPad show the query as having stopped (Execute button enabled, Cancel button disabled)?

    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.
  • Yes, the Execute button is enabled, Cancel button is disabled, and the status message on the bottom shows that the query has finished. I will try the "Cancel all threads and reset" option, thanks!
  • This is still a problem! For massive parallel processing I like to spin up a bunch of TPL Task. However even if I do CTRL+SHIFT+F5 and see the message "Application Domain Unloaded" at the bottom, it will often keep running. The only way to stop it is to close all my LINQPad queries and exit LINQPad, which is very annoying if I have a lot of unsaved queries I'm workoing on.

    Is there a fix for this? There can be some nasty unexpected side effects.
  • The newest beta uses process isolation instead of AppDomain isolation:
    http://www.linqpad.net/beta.aspx

    Try that and let me know.
  • I'm on the beta, and this still happens to me. Hitting the stop button makes the UI appear to have stopped it, but the query continues because there is nothing cancelling running tasks (and hitting run again will get 2 of them going). Cancel all threads and reset works. It would be nice to have an ambient cancellation token available to pass through the tasks to cancel them when you hit stop.
Sign In or Register to comment.