You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We are trying to implement an auto-update of the database in a background task on a Web Service. However, we cannot find a way to close the reader (even when locked) so that the database file can be replaced with a new one. Any thoughts?
The text was updated successfully, but these errors were encountered:
There is a Dispose method that will call Dispose on the underlying MemoryMappedFile. I don't know if this is sufficient for your use case or not.
On a POSIX system, you should be able to atomically replace the file while the database is open, which is what I would recommend. I don't know offhand if this will work as expected on Windows.
Hi @oschwald . Thank you for getting back me so quickly.
I tried dispose and then replacing the file with the new version. However, the file was still locked and the move operation failed. This could also be an Azure / IIS file locking issue.
I'll try to work with multiple files instead for now.
Another option is to use the memory mode rather than the memory-mapped one. This will load the file into memory rather than mapping the file. You can do this with something like new DatabaseReader(dbFile, FileAccessMode.Memory).
We are trying to implement an auto-update of the database in a background task on a Web Service. However, we cannot find a way to close the reader (even when locked) so that the database file can be replaced with a new one. Any thoughts?
The text was updated successfully, but these errors were encountered: