Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9168225
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T15:34:48+00:00 2026-06-17T15:34:48+00:00

This should be pretty easy , but i couldn’t find a adequated term to

  • 0

This should be pretty easy , but i couldn’t find a adequated term to search for… Well I’m new to C# and i’m trying to make a simple App to write the return of a webservice.

I came across the need to use a Thread… passing parameters to the thread is fairly easy , I couldn’t find a way to return from the Threaded method and update my UI to show the result (well actually no the real result for now)

The event:

    private void TextBox_TextChanged_1(object sender, TextChangedEventArgs e)
    {
        minhaSigla = Sigla.Text;
        Task.Factory.StartNew(() => GetQuoteAndUpdateText(minhaSigla));
        tb1.Text = "UIElement-TO-UPDATE";

    }

And then the Threaded method

    private string GetQuoteAndUpdateText(string sign)
    {
        string SoapEnvelope = "";
        SoapEnvelope = "<?xml version=\"1.0\" encoding=\"utf-8\"?>";
        SoapEnvelope += "<soap:Envelope ";
        SoapEnvelope += "xmlns:xsi = \"http://www.w3.org/2001/XMLSchema-instance\" ";
        SoapEnvelope += "xmlns:xsd= \"http://www.w3.org/2001/XMLSchema\" ";
        SoapEnvelope += "xmlns:soap= \"http://schemas.xmlsoap.org/soap/envelope/\">";
        SoapEnvelope += "<soap:Body>";
        SoapEnvelope += "   <GetQuote xmlns=\"http://www.webserviceX.NET/\"> ";
        SoapEnvelope += "       <symbol>" + sign + "</symbol> ";
        SoapEnvelope += "   </GetQuote> ";
        SoapEnvelope += "</soap:Body>";
        SoapEnvelope += "</soap:Envelope>";

        EndpointAddress endpoint = new EndpointAddress("http://www.webservicex.net/stockquote.asmx");
        BasicHttpBinding basicbinding = new BasicHttpBinding();
        basicbinding.SendTimeout = new TimeSpan(3000000000);
        basicbinding.OpenTimeout = new TimeSpan(3000000000);

        stockbyname.StockQuoteSoapClient sbn = new stockbyname.StockQuoteSoapClient(basicbinding, endpoint);

        XmlDocument xmlDocument = new XmlDocument();
        return sbn.GetQuote(SoapEnvelope);
    }

Also any information will be much appreciated, even comments about how awful my code is 😛

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T15:34:49+00:00Added an answer on June 17, 2026 at 3:34 pm

    Without getting into all the fun async/await stuff, you can use the ContinueWith method of Task to handle the returned information.

    private void TextBox_TextChanged_1(object sender, TextChangedEventArgs e)
    {
        minhaSigla = Sigla.Text;
        var quoteGetterTask = Task.Factory.StartNew(() => GetQuoteAndUpdateText(minhaSigla));
        quoteGetterTask.ContinueWith(task => 
        {
            var theResultOfYourServiceCall = task.Result;
            //You'll need to use a dispatcher here to set the value of the text box (see below)
            tb1.Text = theResultOfYourServiceCall;     //"UIElement-TO-UPDATE";
        });
    }
    

    As I mention in the above code sample, depending on which UI technology you’re using you’ll need to use a dispatcher to avoid getting an illegal cross thread access exception.

    WinForms example of the expression inside the .ContinueWith (using the Invoke method of Control)

    task =>
    {
        var theResultOfYourServiceCall = task.Result;
        tb1.Invoke(new Action(() => tb1.Text = theResultOfYourServiceCall));
    }
    

    WPF example of the expression inside the .ContinueWith (using WPF’s Dispatcher)

    task =>
    {
        var theResultOfYourServiceCall = task.Result;
        tb1.Dispatcher.Invoke(DispatcherPriority.Normal, 
                              new Action(() => tb1.Text = theResultOfYourServiceCall));
    }
    

    Silverlight/Windows Phone example of the expression inside the .ContinueWith (using Silverlight’s Dispatcher)

    task =>
    {
        var theResultOfYourServiceCall = task.Result;
        tb1.Dispatcher.BeginInvoke(() => tb1.Text = theResultOfYourServiceCall);
    }
    

    Windows Store example of the expression inside the .ContinueWith (using CoreDispatcher)

    task =>
    {
        var theResultOfYourServiceCall = task.Result;
        tb1.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => tb1.Text = theResultOfYourServiceCall);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This should be pretty simple, but I am new at LINQ. I have a
I'm trying something that should be pretty easy but i can't figure out how
This feels like it should be pretty simple, but not much seems to be
This seems like it should be pretty straight forward, but I'm apparently confused. I
This seems like it should be really easy but I've been having trouble with
So this should be pretty easy, yet I can't get it work. I have
This should be pretty simple, still I can not see what/how something could be
This should be pretty straightforward I would think. I have this string: [quote=Joe Johnson|1]Hi![/quote]
This should be a pretty straightforward question. I have the following code, which forms
I'm running Mysql 5.0.77 and I'm pretty sure this query should work? SELECT *

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.