public UniTask Run() { var t = UniTask.Run(async() => { try { while (true) { // // NOTE: Change this to readwrite and then it does work ??? // No more IOERROR // var flags = SQLiteOpenFlags.FullMutex | SQLiteOpenFlags.ReadOnly; #if __IOS__ flags = SQLiteOpenFlags.FullMutex | SQLiteOpenFlags.ReadWrite; #endif using (var dbConnection = new DbConnection(flags)) { var records = dbConnection.Table <TestObj>().ToList(); System.Diagnostics.Debug.WriteLine($"{Environment.CurrentManagedThreadId} Read records: {records.Count}"); } // sqlite-net : (No await so we stay on the same thread) but UniTask use same thread await UniTask.Delay(10, cancellationToken: cancellationToken); cancellationToken.ThrowIfCancellationRequested(); } } catch (OperationCanceledException) { } }); return(t); }
public UniTask Run() { var t = UniTask.Run(async() => { try { while (true) { using (var dbConnection = new DbConnection(SQLiteOpenFlags.FullMutex | SQLiteOpenFlags.ReadWrite)) { System.Diagnostics.Debug.WriteLine($"{Environment.CurrentManagedThreadId} Start insert"); for (var i = 0; i < 50; i++) { var newRecord = new TestObj() { }; dbConnection.Insert(newRecord); } System.Diagnostics.Debug.WriteLine($"{Environment.CurrentManagedThreadId} Inserted records"); } // sqlite-net : (No await so we stay on the same thread) but UniTask use same thread await UniTask.Delay(1, cancellationToken: cancellationToken); cancellationToken.ThrowIfCancellationRequested(); } } catch (OperationCanceledException) { } }); return(t); }