mirror of
https://github.com/LorisYounger/VPet.git
synced 2024-08-30 18:42:36 +00:00
修复动画系统因闭包陷阱导致不执行正确TaskControl的错误
This commit is contained in:
parent
2f9bf11318
commit
f31f93c52f
@ -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));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -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));
|
||||
});
|
||||
}
|
||||
/// <summary>
|
||||
|
@ -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));
|
||||
});
|
||||
}
|
||||
/// <summary>
|
||||
|
Loading…
Reference in New Issue
Block a user