@@ -123,19 +123,6 @@ public async Task StartAsync()
123123 _batch . Completed -= Batch_Completed ;
124124 }
125125
126- _batch = _compositor . CreateScopedBatch ( CompositionBatchTypes . Animation ) ;
127- _batch . Completed += Batch_Completed ;
128-
129- foreach ( var anim in _animations )
130- {
131- Visual . StartAnimation ( anim . Key , anim . Value ) ;
132- }
133-
134- foreach ( var effect in _effectAnimations )
135- {
136- effect . EffectBrush . StartAnimation ( effect . PropertyName , effect . Animation ) ;
137- }
138-
139126 foreach ( var property in _directPropertyChanges )
140127 {
141128 typeof ( Visual ) . GetProperty ( property . Key ) . SetValue ( Visual , property . Value ) ;
@@ -146,17 +133,37 @@ public async Task StartAsync()
146133 definition . EffectBrush . Properties . InsertScalar ( definition . PropertyName , definition . Value ) ;
147134 }
148135
149- Task compositionTask = Task . Run ( ( ) =>
136+ List < Task > tasks = new List < Task > ( ) ;
137+
138+ if ( _animations . Count > 0 || _effectAnimations . Count > 0 )
150139 {
151- _manualResetEvent . Reset ( ) ;
152- _manualResetEvent . WaitOne ( ) ;
153- } ) ;
140+ _batch = _compositor . CreateScopedBatch ( CompositionBatchTypes . Animation ) ;
141+ _batch . Completed += Batch_Completed ;
154142
155- _batch . End ( ) ;
143+ foreach ( var anim in _animations )
144+ {
145+ Visual . StartAnimation ( anim . Key , anim . Value ) ;
146+ }
147+
148+ foreach ( var effect in _effectAnimations )
149+ {
150+ effect . EffectBrush . StartAnimation ( effect . PropertyName , effect . Animation ) ;
151+ }
152+
153+ Task compositionTask = Task . Run ( ( ) =>
154+ {
155+ _manualResetEvent . Reset ( ) ;
156+ _manualResetEvent . WaitOne ( ) ;
157+ } ) ;
158+
159+ _batch . End ( ) ;
160+
161+ tasks . Add ( compositionTask ) ;
162+ }
156163
157- var storyboardTask = _storyboard . BeginAsync ( ) ;
164+ tasks . Add ( _storyboard . BeginAsync ( ) ) ;
158165
159- await Task . WhenAll ( compositionTask , storyboardTask ) ;
166+ await Task . WhenAll ( tasks ) ;
160167 }
161168
162169 /// <summary>
0 commit comments