-api-id | -api-type |
---|---|
T:Windows.UI.Composition.CompositionCommitBatch |
winrt class |
A group of active animations or effects.
Represents a group of active animations or effects and triggers a callback when all members of the group have completed. A CompositionCommitBatch is implicitly created but must be retrieved in order declare the completed event. A Commit batch will be implicitly closed at the end of each commit cycle.
For an animation batch type, the callback triggers when the combined delay and duration of the longest animation in the batch has elapsed. For an effect batch type, the callback triggers when the processing of all the effects in the batch have completed.
The current Commit batch can be retrieved by calling Compositor.GetCommitBatch at any time during the commit cycle. The commit cycle is defined as the time between updates from the compositor. Updates are queued until the system is ready to process the changes and draw bits to the screen. The Commit batch will aggregate all objects within the commit cycle, those before and after GetCommitBatch was called. The Commit batch is implicitly created on the composition thread, the thread which the compositor is created on. There can only be one compositor per thread hence one Commit batch per thread. A Commit batch must be retrieved in order declare the completed event. A Commit batch will be implicitly closed at the end of each commit cycle and cannot be suspended or resumed, this will result in an error if attempted.
See Composition Animations Overview for more information on composition batches.
Commit Batch
private void UsingCommitBatch()
{
//Create Scoped batch for animations
CompositionCommitBatch batch = Compositor.GetCommitBatch(CompositionBatchTypes.Animation);
//Setup completion event
batch.Completed += CommitBatchCompleted;
//Setup animations
Animation1(_target);
}
// Creates and defines the key frame animation
private void Animation1(Visual targetVisual)
{
var animation1 = _compositor.CreateVector3KeyFrameAnimation();
animation1.InsertKeyFrame(0.0f, new Vector3(100.00f, 100.00f, 0.00f));
animation1.InsertKeyFrame(0.5f, new Vector3(300.00f, 100.00f, 0.00f));
animation1.InsertKeyFrame(1.0f, new Vector3(500.00f, 100.00f, 0.00f));
animation1.Duration = TimeSpan.FromMilliseconds(2000);
targetVisual.StartAnimation("Offset", animation1);
}
public void CommitBatchCompleted(object sender, CompositionBatchCompletedEventArgs args)
{
_root.Children.Remove(_target);
}
Composition Animations Overview, CompositionObject, IClosable, CompositionScopedBatch