File tree Expand file tree Collapse file tree 1 file changed +21
-3
lines changed Expand file tree Collapse file tree 1 file changed +21
-3
lines changed Original file line number Diff line number Diff line change 22//
33// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
44
5- using CefSharp . OffScreen ;
65using System ;
76using System . IO ;
7+ using System . Threading ;
8+ using System . Threading . Tasks ;
9+ using CefSharp . OffScreen ;
810
911namespace CefSharp . Test
1012{
1113 public class CefSharpFixture : IDisposable
1214 {
15+ private readonly TaskScheduler scheduler ;
16+ private readonly Thread thread ;
17+
1318 public CefSharpFixture ( )
1419 {
20+ SynchronizationContext . SetSynchronizationContext ( new SynchronizationContext ( ) ) ;
21+
22+ scheduler = TaskScheduler . FromCurrentSynchronizationContext ( ) ;
23+ thread = Thread . CurrentThread ;
24+
1525 if ( ! Cef . IsInitialized )
1626 {
1727 var isDefault = AppDomain . CurrentDomain . IsDefaultAppDomain ( ) ;
@@ -32,9 +42,17 @@ public CefSharpFixture()
3242
3343 public void Dispose ( )
3444 {
35- if ( Cef . IsInitialized )
45+ var factory = new TaskFactory ( scheduler ) ;
46+
47+ if ( thread . IsAlive )
3648 {
37- Cef . Shutdown ( ) ;
49+ factory . StartNew ( ( ) =>
50+ {
51+ if ( Cef . IsInitialized )
52+ {
53+ Cef . Shutdown ( ) ;
54+ }
55+ } ) ;
3856 }
3957 }
4058 }
You can’t perform that action at this time.
0 commit comments