In my SL4 app, I have a call to a service, svc.SubmitAsync(). Since this is an async call, once the method is hit, my code goes on to the next line. This is fine as long as the user enters the correct user name and password. If they don't, EndSubmit() throws an exception. EndSubmit() is in References.cs, part of the auto-generated Silverlight code.
I tried wrapping svc.SubmitAsync() in a try-catch but this is an async call and the try-catch block completes before the exception is even thrown.
How do I catch this error?
Thanks!
Update 1
public void SubmitTweetAsync(TestSilverlightApp.svc.Tweet tweet, object userState) {
if ((this.onBeginSubmitTweetDelegate == null)) {
this.onBeginSubmitTweetDelegate = new BeginOperationDelegate(this.OnBeginSubmitTweet);
}
if ((this.onEndSubmitTweetDelegate == null)) {
this.onEndSubmitTweetDelegate = new EndOperationDelegate(this.OnEndSubmitTweet);
}
if ((this.onSubmitTweetCompletedDelegate == null)) {
this.onSubmitTweetCompletedDelegate = new System.Threading.SendOrPostCallback(this.OnSubmitTweetCompleted);
}
base.InvokeAsync(this.onBeginSubmitTweetDelegate, new object[] {
tweet}, this.onEndSubmitTweetDelegate, this.onSubmitTweetCompletedDelegate, userState);
}
Update 2 - This is a WCF service.