locked
Are Async WebService Callbacks Automatically Marshaled? RRS feed

  • Question

  • [.NET 2.0]

    I'm wondering if the callback from an async web service call is automatically marshaled to the UI (calling) thread. None of the documentation that I've found clarifies (or even mentions) this. My exploration project seems to indicate that the callback *is* automatically marshaled but I would like a definite answer if I can get one.


    private void DelayedResponse_Callback(object sender, DelayedReponseCompletedEventArgs e)
    {
       if (InvokeRequired)
       {
          DelayedResponse_Callback(sender, e); // Will this ever get executed?
       }
       else
       {
          textBox1.Text = e.Result;
       }
    }

     

    Monday, November 21, 2005 7:11 PM

Answers

  • Hello,

    In .NET v1.1 the async callbacks are not automatically marshalled to the UI thread.  You have to mashall them yourself using a Control.Invoke() call.

    In .NET v2.0, the new event-base async programming model will automatically marshall for you.  Take a look at this sample:

    http://www.asp.net/QuickStart/webservices/doc/RADAsync.aspx

    Daniel Roth

     

    Friday, February 17, 2006 7:26 PM