Simcha Khabinsky
Simcha Khabinsky

Reputation: 2039

VS2010 Keeps Running After "Stop Debugging" (Web API)

I have a ASP.NET 4.0 WEB API application running that modifies some database records.

My code iterates through Orders and Updates:

<[PUT]("ProcessOrders")>
Public Sub PutValue()

   Dim Orders as List(of OrderInfo) = DAL.GetOrders()

   For Each Order As OrderRequest In Orders

       Dim Status As OrderProcessingStatus = Order.Process()

       If (Status.isSuccessfullyProcessed) Then
            DAL.UpdateOrderStatus(Order.OrderNumber, "SUCCESS")
       Else
            DAL.UpdateOrderStatus(Order.OrderNumber, "FAIL", Status.ErrorMessage)
       End If
   Next

End Sub

While debugging in VS2010, I have a break point on the first line where I get the orders. In VS2010, I click on "Stop Debugging" - expecting that my code will immidietly stop and not execute.

To my surprise, even after I clicked Stop Debugging, the code keeps running and updates my database.

Please help.

Note: I start debugging, and then I use Fiddler to call this method

Thanks,

Simcha

Upvotes: 2

Views: 1488

Answers (2)

Simcha Khabinsky
Simcha Khabinsky

Reputation: 2039

Figured it out. Like Adrian McCarthy said:

If the process is started outside the debugger, and then you attach the debugger, the "Stop Debugging" command simply detaches the debugger from the process, and the process continues to run.

In the end, I used the "Terminate All" under the Debug menu. This actually stops all requests/processes.

Upvotes: 5

Adrian McCarthy
Adrian McCarthy

Reputation: 47954

If the process is started outside the debugger, and then you attach the debugger, the "Stop Debugging" command simply detaches the debugger from the process, and the process continues to run.

If you want to stop the process, then start it from the debugger. If that's inconvenient (e.g., if the process is started by another process on some event), then you'll have to kill the process in Task Manager and then stop the debugger.

Upvotes: 2

Related Questions