Error:The read lock is being released without being held.
I'm using litedb in uwp , and I wrapped a Litedatabase instance in a DBManager class. In any case i need operation database ,i will use the db instance without using staments
var db = DBManger.GetDB();
var collection = db.GetCollection
and a concurrency error occured,so what is the right way to work with multithread,can someone supply an example?
found the problem, seems can't use async/await
Hi @swordream, current version do not support async/await. Only sync operations. It's on my plans to next version async support.
Hi David, I am getting the same error:
System.Threading.SynchronizationLockException: The write lock is being released without being held. at System.Threading.ReaderWriterLockSlim.ExitWriteLock () [0x0002a] in <63992662b765477a898ef49cdcc99ee2>:0 at LiteDB.LockService.
I am using lock but still getting the error when using it from multithread: How should I use it then? Thanks Jan
public bool InsertToCache(Data data) { try { lock (Lock) { var col = _db?.GetCollection(_collectionName); col?.Insert(data); return true; } } catch (Exception exception) { Log.Error(exception, "Error inserting entity to cache."); }
return false;
}