public void Thread_FindUpsertEngine_Test() { using (var file = new TempFile()) using (var db = new LiteEngine(file.Filename)) { var tasks = new List <Task>(); for (var i = 0; i < 50; i++) // Change 1000 to whatever value spams it enough. { var ind = i % 50; var tFind = Task.Factory.StartNew(() => { db.FindById("col", BitConverter.GetBytes(ind)); }); var tUpsert = Task.Factory.StartNew(() => { db.Upsert("col", new BsonDocument { { "_id", BitConverter.GetBytes(ind) } }); }); tasks.AddRange(new[] { tFind, tUpsert }); } Task.WaitAll(tasks.ToArray()); } }