cannot workout coroutines

Topics: Actions & Coroutines
Nov 8, 2011 at 7:02 AM
Edited Nov 8, 2011 at 7:03 AM

I need to do synchronous process in Silverlight, so google lead me indirectly to here, using coroutines/sequential-processing.

the sample Caliburn.Micro.Coroutines worked.

But not when i tried changed them to my coding/context, I can't get it worked. The Catalog is not downloaded/excuted within my method. 

        <Button x:Name="GoForward"
                Content="Next" />
        <Button Content="Test" Click="Button_Click" />


        private void Button_Click(object sender, System.Windows.RoutedEventArgs e)
            var vm = this.DataContext as ScreenOneViewModel;

        public void Test()
            var r1 = Loader.Show("Downloading...");
            var r2 = new LoadCatalog("Caliburn.Micro.Coroutines.External.xap");
            //r2.Execute(null); // testing
            var r3 = Loader.Hide();
            var r4 = new ShowScreen("ExternalScreen");
How can I make the LoadCatalog worked to download the file used within Test() method?
Nov 10, 2011 at 3:27 AM

Test should return IEnumerator<IResult> and you should yield r1, r2, etc. Then, you need to use the Coroutine.BeginExecute helper function to call your Test method from the event handler. This is all done automatically if you use Actions. But if you want to do it outside of that context, you have to use the Coroutine helper method.

Nov 14, 2011 at 2:40 AM

I further test the coroutine, it seems like the execution is never carried out/process within the Test() routine. They only worked after program control is left Test().

so if I want to check/expect a stage changes within the Test(), like after r2, to grab the downloaded file content, this will never happen within Test() after r2, right?

Nov 14, 2011 at 12:52 PM

Can you post your updated code?