locked
Running multiple awaited Tasks in order

    Question

  • I am creating an app that requires to execute multiple awaited tasks in order or else the out come is disastrous.

    This current method executes all awaited task almost at the same time. Sometimes the Speech synthesizer runs before the stream is finished being generated or even before the rss feeder data is finished loading.

    here is my code

     private async void RSSreader()
            {
    
                    SyndicationClient client = new SyndicationClient();
    
                    Uri feedUri = new Uri("http://api.breakingnews.com/api/v1/item/?format=rss");
    
                    feed = await client.RetrieveFeedAsync(feedUri);
    
                    foreach (SyndicationItem item in feed.Items)
                    {
                        RSSFEEDBOX.Text = RSSFEEDBOX.Text + "\n" + item.Title.Text + ".";
                    }
    
                    // Read Text From Text Box RSSFEEDBOX
                    stream = await Sn.SynthesizeTextToStreamAsync(RSSFEEDBOX.Text);
                    TextPlayer.SetSource(stream, stream.ContentType);
                    TextPlayer.MediaEnded += TextPlayer_MediaEnded;
                    TextPlayer.Play();
                 
               
            }

     


    Rogelio Rios

    Sunday, March 29, 2015 6:25 AM

Answers

  • The problem is that you have used 'async void'. You should not use 'async void' for methods/functions.

    Change your method's signature to:

    private async Task RSSReader()

    And of course this method should be called asynchronously.


    I'm a self-taught noob amateur. Please take this into account when responding to my posts or when taking advice from me.

    Sunday, March 29, 2015 12:16 PM

All replies

  • Problem is in "almost at the same time".

    Sunday, March 29, 2015 7:42 AM
  • The problem is that you have used 'async void'. You should not use 'async void' for methods/functions.

    Change your method's signature to:

    private async Task RSSReader()

    And of course this method should be called asynchronously.


    I'm a self-taught noob amateur. Please take this into account when responding to my posts or when taking advice from me.

    Sunday, March 29, 2015 12:16 PM