从 C# 处理 TFS 服务器连接
Dispose of TFS server connection from C#
我正在尝试通过 C# 应用程序连接和断开与 TFS 服务器的连接。我可以使用这种方法连接,
TfsConfigurationServer ConfigurationServer = TfsConfigurationServerFactory.GetConfigurationServer(new Uri(serverString));
但我不确定使用什么来断开与服务器的连接。我目前使用
ConfigurationServer.Dispose()
但我不确定这是否只是处理对象或连接本身。我正在尝试关闭连接本身。
如您所见,Dispose() 方法继承自 TfsConnection class,它实现了 IDisposable。从技术上讲,这意味着当在 TfsConfigurationServer 对象上调用 Dispose() 方法时,底层 TfsConnection 将关闭。
可以肯定的是,您可以在调用 Dispose() 后立即检查连接是否仍然打开,方法是在 TfsConfigurationServer 对象上调用 Get*() 方法。
由于 TfsConnection class 上没有 Close() 方法,因此 Dispose() 方法是关闭连接的唯一方法。
是的,TFS 连接 class 中没有 disconnect()
或 close()
方法。
.NET 垃圾收集器或使用 Dispose 方法,这将关闭连接。
请阅读 TfsConnection 的描述 class -- 特别是方法 Dispose TfsConnection.Dispose 方法
您可以参考这里的相关示例:Microsoft.TeamFoundation.Client.TfsConnection.Dispose()
Note: When you disconnect from source control, you are not able to see the source control status of files or access source control
functions.
也看看这个类似的问题:Service running out of TCP connections
我正在尝试通过 C# 应用程序连接和断开与 TFS 服务器的连接。我可以使用这种方法连接,
TfsConfigurationServer ConfigurationServer = TfsConfigurationServerFactory.GetConfigurationServer(new Uri(serverString));
但我不确定使用什么来断开与服务器的连接。我目前使用
ConfigurationServer.Dispose()
但我不确定这是否只是处理对象或连接本身。我正在尝试关闭连接本身。
如您所见,Dispose() 方法继承自 TfsConnection class,它实现了 IDisposable。从技术上讲,这意味着当在 TfsConfigurationServer 对象上调用 Dispose() 方法时,底层 TfsConnection 将关闭。
可以肯定的是,您可以在调用 Dispose() 后立即检查连接是否仍然打开,方法是在 TfsConfigurationServer 对象上调用 Get*() 方法。
由于 TfsConnection class 上没有 Close() 方法,因此 Dispose() 方法是关闭连接的唯一方法。
是的,TFS 连接 class 中没有 disconnect()
或 close()
方法。
.NET 垃圾收集器或使用 Dispose 方法,这将关闭连接。
请阅读 TfsConnection 的描述 class -- 特别是方法 Dispose TfsConnection.Dispose 方法
您可以参考这里的相关示例:Microsoft.TeamFoundation.Client.TfsConnection.Dispose()
Note: When you disconnect from source control, you are not able to see the source control status of files or access source control functions.
也看看这个类似的问题:Service running out of TCP connections