本文整理汇总了C#中System.Data.SqlClient.SqlConnection.GetServicesCount方法的典型用法代码示例。如果您正苦于以下问题:C# SqlConnection.GetServicesCount方法的具体用法?C# SqlConnection.GetServicesCount怎么用?C# SqlConnection.GetServicesCount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Data.SqlClient.SqlConnection
的用法示例。
在下文中一共展示了SqlConnection.GetServicesCount方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ResourcesReleasabilityTest
public void ResourcesReleasabilityTest(int changesCount)
{
using (var sqlConnection = new SqlConnection(TEST_CONNECTION_STRING))
{
sqlConnection.Open();
int sqlConversationEndpointsCount = sqlConnection.GetUnclosedConversationEndpointsCount();
int sqlConversationGroupsCount = sqlConnection.GetConversationGroupsCount();
int sqlServiceQueuesCount = sqlConnection.GetServiceQueuesCount();
int sqlServicesCount = sqlConnection.GetServicesCount();
NotificationTest(changesCount, false);
// Microsoft SqlDependency REMOVES queue and service after use.
Assert.AreEqual(sqlServicesCount, sqlConnection.GetServicesCount());
Assert.AreEqual(
sqlServiceQueuesCount,
sqlConnection.GetServiceQueuesCount());
// Microsoft SqlDependency KEEPS conversation group and endpoint in DB after use.
// This behavior leads to GIANT memory leaks in SQL Server.
Assert.AreNotEqual(
sqlConversationGroupsCount,
sqlConnection.GetConversationGroupsCount());
Assert.AreNotEqual(
sqlConversationEndpointsCount,
sqlConnection.GetUnclosedConversationEndpointsCount());
}
}
示例2: ResourcesReleasabilityTest
public void ResourcesReleasabilityTest(int changesCount)
{
using (var sqlConnection = new SqlConnection(ADMIN_TEST_CONNECTION_STRING))
{
sqlConnection.Open();
int sqlConversationEndpointsCount = sqlConnection.GetUnclosedConversationEndpointsCount();
int sqlConversationGroupsCount = sqlConnection.GetConversationGroupsCount();
int sqlServiceQueuesCount = sqlConnection.GetServiceQueuesCount();
int sqlServicesCount = sqlConnection.GetServicesCount();
int sqlTriggersCount = sqlConnection.GetTriggersCount();
int sqlProceduresCount = sqlConnection.GetProceduresCount();
using (SqlDependencyEx sqlDependency = new SqlDependencyEx(
TEST_CONNECTION_STRING,
TEST_DATABASE_NAME,
TEST_TABLE_NAME, "temp"))
{
sqlDependency.Start();
// Make sure we've created one queue, sevice, trigger and two procedures.
Assert.AreEqual(sqlServicesCount + 1, sqlConnection.GetServicesCount());
Assert.AreEqual(
sqlServiceQueuesCount + 1,
sqlConnection.GetServiceQueuesCount());
Assert.AreEqual(sqlTriggersCount + 1, sqlConnection.GetTriggersCount());
Assert.AreEqual(sqlProceduresCount + 2, sqlConnection.GetProceduresCount());
MakeTableInsertDeleteChanges(changesCount);
// Wait a little bit to process all changes.
Thread.Sleep(1000);
}
// Make sure we've released all resources.
Assert.AreEqual(sqlServicesCount, sqlConnection.GetServicesCount());
Assert.AreEqual(
sqlConversationGroupsCount,
sqlConnection.GetConversationGroupsCount());
Assert.AreEqual(
sqlServiceQueuesCount,
sqlConnection.GetServiceQueuesCount());
Assert.AreEqual(
sqlConversationEndpointsCount,
sqlConnection.GetUnclosedConversationEndpointsCount());
Assert.AreEqual(sqlTriggersCount, sqlConnection.GetTriggersCount());
Assert.AreEqual(sqlProceduresCount, sqlConnection.GetProceduresCount());
}
}