Ich habe eine Anwendung, die ferngesteuert wird. Das Programm muss Animation auf Anfrage und Antwort auf den Client spielen, wenn es fertig ist. Dies ist der Code, den ich jetzt habe (und es funktioniert nicht richtig):Nancy Route - Rückgabewert beim Rückruf
public void PlayAnimation(Action callback)
{
DoubleAnimation fadeOut = new DoubleAnimation
{
//settings
};
fadeOut.Completed += (s, e) => callback();
BeginAnimation(OpacityProperty, fadeOut);
}
Get["/playAnim/{id}"] = param =>
{
MainWindow.PlayAnimation(() => {/* Need to call "return" statement here */});
return "Ok"; // This is where the value is returned now.
//The execution gets here before animation was completed.
};
Ich weiß, Nancy unterstützt auch async-await
Syntax, aber DoubleAnimation
nicht (oder es tut?). Also, wie mache ich Nancy antworten nach die Animation wurde gespielt?