25
25
26
26
namespace Flow . Launcher
27
27
{
28
- public partial class App : IAsyncDisposable , ISingleInstanceApp
28
+ public partial class App : IDisposable , ISingleInstanceApp
29
29
{
30
30
#region Public Properties
31
31
@@ -122,10 +122,9 @@ public static void Main()
122
122
{
123
123
if ( SingleInstance < App > . InitializeAsFirstInstance ( ) )
124
124
{
125
- var application = new App ( ) ;
125
+ using var application = new App ( ) ;
126
126
application . InitializeComponent ( ) ;
127
127
application . Run ( ) ;
128
- application . DisposeAsync ( ) . AsTask ( ) . GetAwaiter ( ) . GetResult ( ) ;
129
128
}
130
129
}
131
130
@@ -240,22 +239,22 @@ private void AutoUpdates()
240
239
241
240
private void RegisterExitEvents ( )
242
241
{
243
- AppDomain . CurrentDomain . ProcessExit += async ( s , e ) =>
242
+ AppDomain . CurrentDomain . ProcessExit += ( s , e ) =>
244
243
{
245
244
Log . Info ( "|App.RegisterExitEvents|Process Exit" ) ;
246
- await DisposeAsync ( ) ;
245
+ Dispose ( ) ;
247
246
} ;
248
247
249
- Current . Exit += async ( s , e ) =>
248
+ Current . Exit += ( s , e ) =>
250
249
{
251
250
Log . Info ( "|App.RegisterExitEvents|Application Exit" ) ;
252
- await DisposeAsync ( ) ;
251
+ Dispose ( ) ;
253
252
} ;
254
253
255
- Current . SessionEnding += async ( s , e ) =>
254
+ Current . SessionEnding += ( s , e ) =>
256
255
{
257
256
Log . Info ( "|App.RegisterExitEvents|Session Ending" ) ;
258
- await DisposeAsync ( ) ;
257
+ Dispose ( ) ;
259
258
} ;
260
259
}
261
260
@@ -279,9 +278,9 @@ private static void RegisterAppDomainExceptions()
279
278
280
279
#endregion
281
280
282
- #region IAsyncDisposable
281
+ #region IDisposable
283
282
284
- protected virtual async ValueTask DisposeAsync ( bool disposing )
283
+ protected virtual void Dispose ( bool disposing )
285
284
{
286
285
// Prevent two disposes at the same time.
287
286
lock ( _disposingLock )
@@ -299,9 +298,7 @@ protected virtual async ValueTask DisposeAsync(bool disposing)
299
298
_disposed = true ;
300
299
}
301
300
302
- await Task . Delay ( 10000 ) ;
303
-
304
- await Stopwatch . NormalAsync ( "|App.Dispose|Dispose cost" , async ( ) =>
301
+ Stopwatch . Normal ( "|App.Dispose|Dispose cost" , async ( ) =>
305
302
{
306
303
Log . Info ( "|App.Dispose|Begin Flow Launcher dispose ----------------------------------------------------" ) ;
307
304
@@ -310,19 +307,19 @@ await Stopwatch.NormalAsync("|App.Dispose|Dispose cost", async () =>
310
307
API ? . SaveAppAllSettings ( ) ;
311
308
await PluginManager . DisposePluginsAsync ( ) ;
312
309
313
- // Dispose needs to be called on the main Windows thread, since some resources owned by the thread need to be disposed.
314
- await _mainWindow ? . Dispatcher . InvokeAsync ( _mainWindow . Dispose ) ;
310
+ // Dispose needs to be called on the main Windows thread,
311
+ // since some resources owned by the thread need to be disposed.
312
+ _mainWindow ? . Dispatcher . Invoke ( _mainWindow . Dispose ) ;
315
313
_mainVM ? . Dispose ( ) ;
316
314
}
317
315
318
316
Log . Info ( "|App.Dispose|End Flow Launcher dispose ----------------------------------------------------" ) ;
319
317
} ) ;
320
318
}
321
319
322
- public async ValueTask DisposeAsync ( )
320
+ public void Dispose ( )
323
321
{
324
- // Do not change this code. Put cleanup code in 'DisposeAsync(bool disposing)' method
325
- await DisposeAsync ( disposing : true ) ;
322
+ Dispose ( disposing : true ) ;
326
323
GC . SuppressFinalize ( this ) ;
327
324
}
328
325
0 commit comments