code de rappel en C#:Comment passer des paramètres à un rappel?
private void CallbackVisibleButton(IAsyncResult ar)
{
AsynchronousVisibleButtonDelegate asyncDeleg = (AsynchronousVisibleButtonDelegate)ar.AsyncState;
b.Visibility = asyncDeleg.EndInvoke(ar);// b - not see!
}
private delegate Visibility AsynchronousVisibleButtonDelegate(Button b);
private Visibility AsynchronousVisibleButton(Button b)
{
Thread.Sleep(2000);
return Visibility.Visible;
}
et createted (b est Bouton, 5 secondes après que le bouton doit être visible):
AsynchronousVisibleButtonDelegate asyncDeleg = new AsynchronousVisibleButtonDelegate(AsynchronousVisibleButton);
AsyncCallback callback = new AsyncCallback(CallbackVisibleButton);
asyncDeleg.BeginInvoke(b, callback, asyncDeleg);
problème: CallbackVisibleButton - ne voit pas le bouton