locked
What happens to SQL query/child thread if application exits? RRS feed

  • Question

  • I have an SQL procedure that runs for few minutes. I call it from UI using BackgroundWorker. I have not implmented Cancel on the background thread or on the Sql Execute call.

    If the application is exited, while my query is running:

    1.) What happens to the running SQL Procedure?

    2.) What happens to the background thread?

    Thanks.

    • Moved by Min Zhu Tuesday, October 9, 2012 7:39 AM not a wpf question (From:Windows Presentation Foundation (WPF))
    Thursday, October 4, 2012 9:30 AM

Answers

  • Hi,

    I might be wrong but I believe your sql proc will continue executing and that your background worker thread will stop executing so it won't be alive to handle any data returned from your sp.

    A background worker makes use of the threadpool and those threads by default are background threads (they stop when when app closes).

    Like I said I might be wrong.

    Thursday, October 4, 2012 10:18 AM
  • I would assume the SQL Proc would keep running, this is at least the behaviour if you try to generate a Report from Reporting Services and close the Webbrowser, the SQL keeps running regardless. To get a more info on SQL behaviour, you can try ask in the SQL forums: http://social.technet.microsoft.com/Forums/en-US/sqldatabaseengine/threads

    The thread is supposed to end with the process

    Florian

    Tuesday, October 9, 2012 10:33 AM
    Answerer

All replies

  • Hi,

    I might be wrong but I believe your sql proc will continue executing and that your background worker thread will stop executing so it won't be alive to handle any data returned from your sp.

    A background worker makes use of the threadpool and those threads by default are background threads (they stop when when app closes).

    Like I said I might be wrong.

    Thursday, October 4, 2012 10:18 AM
  • I would assume the SQL Proc would keep running, this is at least the behaviour if you try to generate a Report from Reporting Services and close the Webbrowser, the SQL keeps running regardless. To get a more info on SQL behaviour, you can try ask in the SQL forums: http://social.technet.microsoft.com/Forums/en-US/sqldatabaseengine/threads

    The thread is supposed to end with the process

    Florian

    Tuesday, October 9, 2012 10:33 AM
    Answerer