@@ -20,7 +20,6 @@ namespace Microsoft.Diagnostics.DebugServices.Implementation
2020 public class Runtime : IRuntime , IDisposable
2121 {
2222 private readonly ClrInfo _clrInfo ;
23- private readonly IDisposable _onFlushEvent ;
2423 private readonly ISymbolService _symbolService ;
2524 private Version _runtimeVersion ;
2625 private string _dacFilePath ;
@@ -52,24 +51,19 @@ public Runtime(IServiceProvider services, int id, ClrInfo clrInfo)
5251 _serviceContainer . AddService < IRuntime > ( this ) ;
5352 _serviceContainer . AddService ( clrInfo ) ;
5453
55- _onFlushEvent = Target . OnFlushEvent . Register ( Flush ) ;
56-
5754 Trace . TraceInformation ( $ "Created runtime #{ id } { clrInfo . Flavor } { clrInfo } ") ;
5855 }
5956
6057 void IDisposable . Dispose ( )
61- {
62- _serviceContainer . RemoveService ( typeof ( IRuntime ) ) ;
63- _serviceContainer . DisposeServices ( ) ;
64- _onFlushEvent . Dispose ( ) ;
65- }
66-
67- private void Flush ( )
6858 {
6959 if ( _serviceContainer . TryGetCachedService ( typeof ( ClrRuntime ) , out object service ) )
7060 {
71- ( ( ClrRuntime ) service ) . FlushCachedData ( ) ;
61+ // The DataTarget created in the RuntimeProvider is disposed here. The ClrRuntime
62+ // instance is disposed below in DisposeServices().
63+ ( ( ClrRuntime ) service ) . DataTarget . Dispose ( ) ;
7264 }
65+ _serviceContainer . RemoveService ( typeof ( IRuntime ) ) ;
66+ _serviceContainer . DisposeServices ( ) ;
7367 }
7468
7569 #region IRuntime
0 commit comments