File tree 1 file changed +3
-1
lines changed
1 file changed +3
-1
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ public abstract class BackgroundDataProvider : IDisposable
10
10
public bool IsRunning { get ; set ; } = false ;
11
11
private CancellationTokenSource _cancellationTokenSource ;
12
12
private CancellationToken _token ;
13
+ private Task _backgroundThread ;
13
14
14
15
public BackgroundDataProvider ( int id )
15
16
{
@@ -18,7 +19,7 @@ public BackgroundDataProvider(int id)
18
19
#endif
19
20
_cancellationTokenSource = new CancellationTokenSource ( ) ;
20
21
_token = _cancellationTokenSource . Token ;
21
- Task . Run ( ( ) => RunBackgroundThreadAsync ( id , _token ) ) ;
22
+ _backgroundThread = Task . Run ( ( ) => RunBackgroundThreadAsync ( id , _token ) ) ;
22
23
}
23
24
24
25
private void OnEditorClose ( )
@@ -58,6 +59,7 @@ public void Dispose()
58
59
UnityEditor . EditorApplication . quitting -= OnEditorClose ;
59
60
#endif
60
61
_cancellationTokenSource ? . Cancel ( ) ;
62
+ _backgroundThread . Wait ( ) ;
61
63
_cancellationTokenSource ? . Dispose ( ) ;
62
64
_cancellationTokenSource = null ;
63
65
}
You can’t perform that action at this time.
0 commit comments