|
|
@@ -78,6 +78,8 @@ namespace VehicleControlSystem.ControlLayer.IO
|
|
|
|
|
|
Thread _readThread;
|
|
|
|
|
|
+ ThreadCancel threadCancel = new ThreadCancel();
|
|
|
+
|
|
|
bool isConnectError = false;
|
|
|
public bool IsConnectError
|
|
|
{
|
|
|
@@ -396,16 +398,19 @@ namespace VehicleControlSystem.ControlLayer.IO
|
|
|
}
|
|
|
public void ThreadStart()
|
|
|
{
|
|
|
- this.IsThreadAlive = true;
|
|
|
- this._readThread = ThreadUtils.Invoke( IOThread );
|
|
|
+ this.threadCancel.AddGo( new Action( this.IOThread ) );
|
|
|
+ this.threadCancel.AddGo( new Action( this.PullQueueThread ) );
|
|
|
|
|
|
- this.pullThread = ThreadUtils.Invoke( PullQueueThread );
|
|
|
+ //this.IsThreadAlive = true;
|
|
|
+ //this._readThread = ThreadUtils.Invoke( IOThread );
|
|
|
+
|
|
|
+ //this.pullThread = ThreadUtils.Invoke( PullQueueThread );
|
|
|
}
|
|
|
void IOThread()
|
|
|
{
|
|
|
var sTime = SwUtils.CurrentTimeMillis;
|
|
|
|
|
|
- while ( IsThreadAlive )
|
|
|
+ while ( !this.threadCancel.Canceled )
|
|
|
{
|
|
|
Thread.Sleep( 5 );
|
|
|
try
|
|
|
@@ -551,7 +556,7 @@ namespace VehicleControlSystem.ControlLayer.IO
|
|
|
|
|
|
void PullQueueThread()
|
|
|
{
|
|
|
- while ( IsThreadAlive )
|
|
|
+ while ( !this.threadCancel.Canceled )
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
@@ -567,6 +572,8 @@ namespace VehicleControlSystem.ControlLayer.IO
|
|
|
DelegateUtils.Invoke( OnWriteIO, o.Arg0 );
|
|
|
else if ( o is QoLog )
|
|
|
DelegateUtils.Invoke( OnLog, o.Arg0, o.Arg1 );
|
|
|
+ else if ( o is QoDispose )
|
|
|
+ break;
|
|
|
else
|
|
|
Assert.Fail( "Unk Object {0}", o );
|
|
|
}
|
|
|
@@ -636,12 +643,16 @@ namespace VehicleControlSystem.ControlLayer.IO
|
|
|
|
|
|
public int Terminate()
|
|
|
{
|
|
|
- this.IsThreadAlive = false;
|
|
|
- if ( this._readThread != null && this._readThread.IsAlive )
|
|
|
- {
|
|
|
- if ( !this._readThread.Join( 3000 ) )
|
|
|
- this._readThread.Abort();
|
|
|
- }
|
|
|
+ this.threadCancel.Cancel();
|
|
|
+ this.qQ.Enqueue( new QoDispose() );
|
|
|
+
|
|
|
+ //this.IsThreadAlive = false;
|
|
|
+ //if ( this._readThread != null && this._readThread.IsAlive )
|
|
|
+ //{
|
|
|
+ // if ( !this._readThread.Join( 3000 ) )
|
|
|
+ // this._readThread.Abort();
|
|
|
+ //}
|
|
|
+ this.threadCancel.StopWaitAll();
|
|
|
|
|
|
this.BoardList.ForEach( b =>
|
|
|
{
|