Skip to content

Commit

Permalink
更新 TaskSchedulerEx 和数据库连接字符串
Browse files Browse the repository at this point in the history
  • Loading branch information
0611163 committed May 27, 2023
1 parent adc83df commit 6a57594
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
4 changes: 2 additions & 2 deletions Dapper.Lite/Dapper.LiteTest/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
<connectionStrings>
<!--数据库连接-->
<!--<add name="DefaultConnection" connectionString="Data Source=sqlite.db;Version=3;"/>-->
<add name="DefaultConnection" connectionString="server=localhost;database=litesql_test;user id=root;password=123456;character set=utf8mb4; min pool size=10; max pool size=50;" />
<!--<add name="DefaultConnection" connectionString="server=192.168.137.62;database=litesql_test;user id=root;password=abc.123;character set=gbk; min pool size=10; max pool size=50;"/>-->
<add name="DefaultConnection" connectionString="server=localhost;database=litesql_test;user id=root;password=123456;character set=utf8mb4;" />
<!--<add name="DefaultConnection" connectionString="server=192.168.137.62;database=litesql_test;user id=root;password=abc.123;character set=gbk; min pool size=10; max pool size=100;"/>-->
</connectionStrings>
<system.net>
<connectionManagement>
Expand Down
8 changes: 3 additions & 5 deletions Dapper.Lite/Utils/TaskSchedulerEx.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ public class TaskSchedulerEx : TaskScheduler, IDisposable
private int _auxiliaryThreadTimeOut = 20000; //辅助线程释放时间
private int _activeThreadCount = 0;
private System.Timers.Timer _timer;
private object _lockCreateTimer = new object();
private bool _run = true;
private Semaphore _sem = null;
private int _semMaxCount = int.MaxValue; //可以同时授予的信号量的最大请求数
Expand Down Expand Up @@ -177,18 +176,17 @@ private void CreateThread()
thread = new Thread(new ThreadStart(() =>
{
Task task;
DateTime dt = DateTime.Now;
while (_run && DateTime.Now.Subtract(dt).TotalMilliseconds < _auxiliaryThreadTimeOut)
while (_run)
{
if (_tasks.TryDequeue(out task))
{
TryExecuteTask(task);
Interlocked.Decrement(ref _runCount);
dt = DateTime.Now;
}
else
{
_sem.WaitOne(_auxiliaryThreadTimeOut);
bool bl = _sem.WaitOne(_auxiliaryThreadTimeOut);
if (!bl) break;
Interlocked.Decrement(ref _semCount);
}
}
Expand Down

0 comments on commit 6a57594

Please sign in to comment.