Skip to content

Commit

Permalink
还是主从备的问题。
Browse files Browse the repository at this point in the history
  • Loading branch information
cyq1162 committed Nov 15, 2017
1 parent a7b57af commit b16e800
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions DAL/DbBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -887,10 +887,10 @@ public void Dispose()
internal bool TestConn()
{
openOKFlag = -1;
Thread thread = new Thread(TestOpen);
Thread thread = new Thread(new ParameterizedThreadStart(TestOpen));
thread.IsBackground = true;
thread.Priority = ThreadPriority.Highest;
thread.Start();
thread.Start(null);
int sleepTimes = 0;
while (openOKFlag == -1)
{
Expand All @@ -905,7 +905,7 @@ internal bool TestConn()
return openOKFlag == 1;
}
private int openOKFlag = -1;
private void TestOpen()
private void TestOpen(object para)
{
try
{
Expand Down Expand Up @@ -942,6 +942,7 @@ private void TestOpen()
openOKFlag = 0;
useConnBean.IsOK = false;
debugInfo.Append(err.Message);

}
}

Expand All @@ -960,7 +961,13 @@ private void ResetConn(ConnBean cb)//, bool isAllowReset
}
internal bool OpenCon()
{
bool result = OpenCon(connObject.Master);
ConnBean master = connObject.Master;
if (!master.IsOK && connObject.BackUp != null && connObject.BackUp.IsOK)
{
master = connObject.BackUp;
connObject.InterChange();//主从换位置
}
bool result = OpenCon(master);
if (_IsAllowRecordSql)
{
connObject.SetNotAllowSlave();
Expand Down

0 comments on commit b16e800

Please sign in to comment.