diff --git a/VPet-Simulator.Core/Graph/FoodAnimation.cs b/VPet-Simulator.Core/Graph/FoodAnimation.cs index ac42a03..948cf98 100644 --- a/VPet-Simulator.Core/Graph/FoodAnimation.cs +++ b/VPet-Simulator.Core/Graph/FoodAnimation.cs @@ -250,7 +250,8 @@ namespace VPet_Simulator.Core return; } nowid = 0; - Control = new TaskControl(EndAction); + var NEWControl = new TaskControl(EndAction); + Control = NEWControl; parant.Dispatcher.Invoke(() => { parant.Tag = this; @@ -276,7 +277,7 @@ namespace VPet_Simulator.Core } t1?.Start(); t2?.Start(); - Task.Run(() => Animations[0].Run(FoodGrid.Food, Control)); + Task.Run(() => Animations[0].Run(FoodGrid.Food, NEWControl)); }); } } diff --git a/VPet-Simulator.Core/Graph/PNGAnimation.cs b/VPet-Simulator.Core/Graph/PNGAnimation.cs index 1d77317..47670a5 100644 --- a/VPet-Simulator.Core/Graph/PNGAnimation.cs +++ b/VPet-Simulator.Core/Graph/PNGAnimation.cs @@ -265,12 +265,13 @@ namespace VPet_Simulator.Core return; } nowid = 0; - Control = new TaskControl(EndAction); + var NEWControl = new TaskControl(EndAction); + Control = NEWControl; parant.Dispatcher.Invoke(() => { if (parant.Tag == this) { - Task.Run(() => Animations[0].Run((System.Windows.Controls.Image)parant.Child, Control)); + Task.Run(() => Animations[0].Run((System.Windows.Controls.Image)parant.Child, NEWControl)); return; } System.Windows.Controls.Image img; @@ -304,7 +305,7 @@ namespace VPet_Simulator.Core parant.Tag = this; img.Source = new BitmapImage(new Uri(Path)); img.Width = Width; - Task.Run(() => Animations[0].Run((System.Windows.Controls.Image)parant.Child, Control)); + Task.Run(() => Animations[0].Run((System.Windows.Controls.Image)parant.Child, NEWControl)); }); } /// diff --git a/VPet-Simulator.Core/Graph/Picture.cs b/VPet-Simulator.Core/Graph/Picture.cs index 6cbecfc..37e45c9 100644 --- a/VPet-Simulator.Core/Graph/Picture.cs +++ b/VPet-Simulator.Core/Graph/Picture.cs @@ -90,7 +90,8 @@ namespace VPet_Simulator.Core Control.EndAction = EndAction; return; } - Control = new TaskControl(EndAction); + var NEWControl = new TaskControl(EndAction); + Control = NEWControl; parant.Dispatcher.Invoke(() => { @@ -127,7 +128,7 @@ namespace VPet_Simulator.Core img.Source = new BitmapImage(new Uri(Path)); parant.Tag = this; } - Task.Run(() => Run(Control)); + Task.Run(() => Run(NEWControl)); }); } ///