File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -23,8 +23,8 @@ public class SessionDataSet: System.IDisposable
2323 private int _rowIndex ;
2424 private bool _hasCatchedResult ;
2525 private RowRecord _cachedRowRecord ;
26- private readonly bool _isClosed = false ;
27-
26+ private bool _isClosed = false ;
27+ private bool disposedValue ;
2828
2929 private string TimestampStr => "Time" ;
3030 private int StartIndex => 2 ;
@@ -295,7 +295,7 @@ public async Task Close()
295295
296296 try
297297 {
298- await myClient . ServiceClient . closeOperationAsync ( req ) ;
298+ var status = await myClient . ServiceClient . closeOperationAsync ( req ) ;
299299 }
300300 catch ( TException e )
301301 {
@@ -307,16 +307,33 @@ public async Task Close()
307307 }
308308 }
309309 }
310- ~ SessionDataSet ( )
310+
311+ protected virtual void Dispose ( bool disposing )
311312 {
312- this . Dispose ( ) ;
313+ if ( ! disposedValue )
314+ {
315+ if ( disposing )
316+ {
317+ try
318+ {
319+ this . Close ( ) . Wait ( ) ;
320+ }
321+ catch
322+ {
323+ }
324+ }
325+ _queryDataset = null ;
326+ _timeBuffer = null ;
327+ _valueBufferLst = null ;
328+ _bitmapBufferLst = null ;
329+ disposedValue = true ;
330+ }
313331 }
314332
315-
316333 public void Dispose ( )
317334 {
318- this . Close ( ) . Wait ( ) ;
319-
335+ Dispose ( disposing : true ) ;
336+ GC . SuppressFinalize ( this ) ;
320337 }
321338 }
322339}
Original file line number Diff line number Diff line change 1414
1515namespace Apache . IoTDB
1616{
17- public class SessionPool
17+
18+ public class SessionPool : IDisposable
1819 {
1920 private static int SuccessCode => 200 ;
2021 private static readonly TSProtocolVersion ProtocolVersion = TSProtocolVersion . IOTDB_SERVICE_PROTOCOL_V3 ;
@@ -104,7 +105,9 @@ public SessionPool(
104105 _enableRpcCompression = enableRpcCompression ;
105106 }
106107
107- ILoggerFactory factory ;
108+ ILoggerFactory factory ;
109+ private bool disposedValue ;
110+
108111 public void OpenDebugMode ( Action < ILoggingBuilder > configure )
109112 {
110113 _debugMode = true ;
@@ -2091,15 +2094,28 @@ public async Task<List<string>> ShowPathsTemplateUsingOnAsync(string templateNam
20912094 {
20922095 _clients . Add ( client ) ;
20932096 }
2094- }
2095-
2096-
2097-
2098-
2099-
2100-
2101-
2102-
2103-
2097+ }
2098+
2099+ protected virtual void Dispose ( bool disposing )
2100+ {
2101+ if ( ! disposedValue )
2102+ {
2103+ if ( disposing )
2104+ {
2105+ #if NET461_OR_GREATER || NETSTANDARD2_0
2106+ #else
2107+ _clients . ClientQueue . Clear ( ) ;
2108+ #endif
2109+ }
2110+ _clients = null ;
2111+ disposedValue = true ;
2112+ }
2113+ }
2114+
2115+ public void Dispose ( )
2116+ {
2117+ Dispose ( disposing : true ) ;
2118+ GC . SuppressFinalize ( this ) ;
2119+ }
21042120 }
21052121}
You can’t perform that action at this time.
0 commit comments