0

I have a single-threaded C# commandline app that uses MongoDB.Driver 2.11.6. On launch it creates a MongoClient instance, checks a redis value, and exits (because in my test scenario the redis value tells the app that there's no work to be done). It exits by leaving my Program.Main() method. This app is built with msbuild (16.1.85) and targeted to run in mono (6.8.0.123).

However it seems that even when I exit Program.Main(), my mono process never exits. I ran it under mono using '--trace' and discovered that there's still a lot of mongo/bson IO activity happening. Is there anything I need to do to tear down any underlying Mongo processing? My version of MongoClient doesn't have any Dispose() or Close() calls so I'm stumped as to how I can get my mongo client to stop. I didn't see anything relevant in MongoClientSettings either btw.

[EDIT] To be clear, my app tries to exit normally after finding no work to be done, so no mongo queries are even made. I'm simply creating a MongoClient instance.

Thanks in advance, Jeff

  • Maybe share a bit of code?... Just guessing i would say there is somewhere where you could use a [USING](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/using-statement) block which would fix your issue, I've had similar odd behaviours with files in the past – Rafa Feb 24 '21 at 10:52
  • Also found this [properly-shutting-down-mongodb-database-connection-from-c-sharp-2-1-driver](https://stackoverflow.com/questions/32703051/properly-shutting-down-mongodb-database-connection-from-c-sharp-2-1-driver) – Rafa Feb 24 '21 at 10:59

0 Answers0