Xamarin 是否需要关闭sqlite的连接

Xamarin 是否需要关闭sqlite的连接,xamarin,android-sqlite,Xamarin,Android Sqlite,我在很多教程中都读到过,没有必要关闭xamarin sqlite中的连接,因为它不像ADO.NET中的连接,它就像Entityframework中的DbContext,但在一些教程中,据说有必要关闭连接 这是xamarin代码 专用只读SQLiteAsyncConnection\u连接; 公众体验() { 初始化组件(); _connection=DependencyService.Get().GetConnection(); } 是否有必要关闭连接?我认为没有必要关闭连接,但它是一个IDis

我在很多教程中都读到过,没有必要关闭xamarin sqlite中的连接,因为它不像ADO.NET中的连接,它就像Entityframework中的DbContext,但在一些教程中,据说有必要关闭连接

这是xamarin代码

专用只读SQLiteAsyncConnection\u连接;
公众体验()
{
初始化组件();
_connection=DependencyService.Get().GetConnection();
}

是否有必要关闭连接?

我认为没有必要关闭连接,但它是一个IDisposable对象,您应该如何处理它或使用using语句

using(SqlConnection connection = new SqlConnection("ConnectionString"))
    {
         // some code here
     }

为了线程安全,建议在每次使用后关闭数据库。
using(SqlConnection connection = new SqlConnection("ConnectionString"))
    {
         // some code here
     }