This commit is contained in:
pypy
2020-11-02 01:11:14 +09:00
parent a2e8b5e5c9
commit ab3bbc6d68
+23 -8
View File
@@ -4,7 +4,6 @@ using System.Collections.Generic;
using System.Data.SQLite;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
namespace VRCX
{
@@ -40,6 +39,8 @@ namespace VRCX
public int ExecuteNonQuery(string sql, IDictionary<string, object> args = null)
{
int result = -1;
m_ConnectionLock.EnterWriteLock();
try
{
@@ -52,22 +53,27 @@ namespace VRCX
command.Parameters.Add(new SQLiteParameter(arg.Key, arg.Value));
}
}
return command.ExecuteNonQuery();
result = command.ExecuteNonQuery();
}
}
catch
{
}
finally
{
m_ConnectionLock.ExitWriteLock();
}
return result;
}
public void Execute(IJavascriptCallback rowCallback, IJavascriptCallback doneCallback, string sql, IDictionary<string, object> args = null)
public void Execute(IJavascriptCallback fetchCallback, IJavascriptCallback resolveCallback, IJavascriptCallback rejectCallback, string sql, IDictionary<string, object> args = null)
{
try
{
m_ConnectionLock.EnterReadLock();
try
{
using (rowCallback)
using (doneCallback)
using (var command = new SQLiteCommand(sql, m_Connection))
{
if (args != null)
@@ -83,16 +89,25 @@ namespace VRCX
{
var values = new object[reader.FieldCount];
reader.GetValues(values);
rowCallback.ExecuteAsync(values);
}
doneCallback.ExecuteAsync();
fetchCallback.ExecuteAsync(values);
}
}
}
resolveCallback.ExecuteAsync();
}
finally
{
m_ConnectionLock.ExitReadLock();
}
}
catch (Exception e)
{
rejectCallback.ExecuteAsync(e.ToString());
}
fetchCallback.Dispose();
resolveCallback.Dispose();
rejectCallback.Dispose();
}
}
}