Calling Web Services using AsyncCallback

John Burkhardt <[email protected]>
Newsgroups gmane.comp.windows.devel.dotnet.general
Message-ID <[email protected]>
I'm trying to do this for the first time.  While I can't send the exact
code, here is in essence what I'm doing:

public void CallMyService()
{
  MyService service = new MyService();
  service.BeginCallMethod(
        new AsyncCallback(this.CallMethodResultCallback),
      service
   );
}

public void CallMethodResultCallback(IAsyncResult ar)
{
   MyService service = (MyService)ar.AsyncState;
   string result = service.EndCallMethod(ar);
   ...
}

So the callback happens, and if I set a break point, I can get the result.
But sometime soon afterward I get a "System.IO.IOException" with the
following message:
"Unable to read data from the transport connection"

Call stack says I'm in System.Net.Connection::ReadCallback()

This does seem to happen when I try to put the string in a UI control.  Is
this not allowed?  Is there a way to create the AsyncCallback such that it
will be called on the UI thread?

Thanks for any help!

-John

You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.