views:

19

answers:

0

I'm using Windows Workflow with SqlWorkflowPersistenceService. I initialize SqlWorkflowPersistenceService with a connection string and everything works fine.

Using the Activity Monitor in SQL Server Management Studio, I can see that the SqlWorkflowPersistenceService executes stored procedures in the database.

When I stop my Windows service, sometimes connections opened by SqlWorkflowPersistenceService are not closed. 9 times out of 10, all database connections are closed when stopping my service but sometimes one database connection is kept open even though my service has stopped.

In the Onstop() function in my Windows service, I call:

        _workflowRuntime.StopRuntime();
        _workflowRuntime.Dispose();

(_workflowRuntime is of type WorkflowRuntime). I thought that this would be enough to close all connections.

Edit: Usign the Activity Monitor, I can see that the last statement the orphaned connection executes is the RetrieveExpiredTimerIds stored procedure. When I start the workflow runtime it opens up another connection as well, but this is always closed. The problem always occur with the connection executing RetrieveExpiredTimerIds.

Why aren't all connections closed when stopping my service?