简体   繁体   中英

How Mongo .Net Driver closes the connection

I have an application that makes 5 queries at the same time and I might need to exit the application before all of them are done, I would like to know how can I cancel all current operations that my MongoClient is making and close the connection.

From what I read at another question in stackoverflow, there's no need to close or dispose of connections in MongoClient because the client handles it automatically so the client will close the connection when the application exits but will the client wait for those queries to finish before closing automatically or will it immediately close? If it waits, how can I make it cancel those queries and close the connection immediately rather than waitting?

如果您需要强制处置 mongoClient,请尝试以下操作:

ClusterRegistry.Instance.UnregisterAndDisposeCluster(client.Cluster)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM