Loading ...
Sorry, an error occurred while loading the content.

Re: Error handling on Asynchronous method calls

Expand Messages
  • charlescookuk
    Hi Lorns - the AsyncCallback delegate can be constructed using either a static or instance method. - Charles
    Message 1 of 5 , Aug 31, 2006
    View Source
    • 0 Attachment
      Hi Lorns - the AsyncCallback delegate can be constructed using either
      a static or instance method.

      - Charles

      --- In XMLRPCNET@yahoogroups.com, "lorns_gandia" <lorns_gandia@...> wrote:
      >
      > Hi,
      >
      > Just would like to ask if it is really necessary to declare the
      > callback method as static method instead of an instance method? I am
      > not sure if this could be the cause of missing data in my
      > application. I hope you could give me some info on this.
      >
      > Thanks.
      >
      > --- In XMLRPCNET@yahoogroups.com, "Charles Cook" <chascook@> wrote:
      > >
      > > Hi Lorns - the call to EndLogUser in the callback method should
      > throw an
      > > exception in the connection fails.
      > >
      > > - Charles
      > >
      > > On 8/22/06, lorns_gandia <lorns_gandia@> wrote:
      > > >
      > > > Hi,
      > > >
      > > > I'm working on an application that makes asynchronous method
      > calls (I
      > > > based this code on AsychBetty sample app). The application works
      > fine
      > > > however, can you possibly help me on how I could handle the
      > exception
      > > > thrown when the application cannot connect to the specified URL
      > > > (XmlRpcClientProtocol). Where should I place the error handling
      > > > method for this, given the sample code below. THANKS!!!
      > > >
      > > > static void GetLogUser(IAsyncResult result)
      > > > {
      > > > XmlRpcAsyncResult clientResult = (XmlRpcAsyncResult)result;
      > > > IUserEvents iue = (IUserEvents)
      > > > clientResult.ClientProtocol;
      > > > UserAsyncState asyncState = (UserAsyncState)result.AsyncState;
      > > > try
      > > > {
      > > > iue obj = iue.EndLogUser (result);
      > > > }
      > > > catch (Exception ex)
      > > > {
      > > > }
      > > > }
      > > >
      > > > public void logUser(int userID, string userName)
      > > > {
      > > > try
      > > > {
      > > > AsyncCallback acb = new AsyncCallback(GetLogUser);
      > > > UserAsyncState asyncState = new UserAsyncState(userID,userName);
      > > > IAsyncResult asr = APIEventsProxy.BeginLogUser (userID,
      > > > userName, acb,asyncState);
      > > > if (asr.CompletedSynchronously)
      > > > {
      > > > object obj = APIEventsProxy.EndLogUser(asr);
      > > > }
      > > > }
      > > > catch (Exception ex)
      > > > {
      > > > }
      > > > }
      > > >
      > > > Sincerely yours,
      > > > Lorns
      > > >
      > > >
      > > >
      > >
      > >
      > > [Non-text portions of this message have been removed]
      > >
      >
    Your message has been successfully submitted and would be delivered to recipients shortly.