locked
Launch multiple URLs simultaneously with IE?

    Question

  • I want to launch multiple URLs from my app into Internet Explorer simultaneously. Similar to how you can have multiple home pages and each one opens in a separate tab when you launch your browser.

    I have some working code that achieves this, but it doesn't work correctly/fully. When I run this code and try to open 4 or 5 URLs at the same time I will only get 2 or 3 of the URLs actually opening in IE (it's inconsistent). It's as if once the links start launching in IE my app's commands get ignored. It doesn't make a difference if I set my app to stay on half of the screen or let IE take over the whole screen.

    I want to build an app that creates grouped favourites that can be opened in a single action as I find myself visiting groups of websites at the same time and end up opening each favourite individually, which is a pain.

    Here is the code I'm using. Is there any way to get this to work?

        public sealed partial class MainPage : Page
        {
            LauncherOptions options = new LauncherOptions();
            public MainPage()
            {
                this.InitializeComponent();
    
                options.DesiredRemainingView = Windows.UI.ViewManagement.ViewSizePreference.UseLess;
                this.GotFocus += MainPage_GotFocus;
            }
    
            void MainPage_GotFocus(object sender, RoutedEventArgs e)
            {
                this.GotFocus -= MainPage_GotFocus;
                LaunchLinks();
            }
    
            private void Button_Click(object sender, RoutedEventArgs e)
            {
                LaunchLinks();
            }
    
            public async void ShowLink(string url)
            {
                          
                await Launcher.LaunchUriAsync(new Uri(url), options);   
            }
    
            public void LaunchLinks()
            {
           
                ShowLink("https://pubcenter.microsoft.com/");
                ShowLink("https://appdev.microsoft.com/StorePortals/en-us/Home/Index");
                ShowLink("https://dev.windowsphone.com/en-us/dashboard");
                ShowLink("http://www.bing.com/");
                ShowLink("http://www.google.com/");
            
            }


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

    Tuesday, August 26, 2014 9:42 AM

Answers

  • It sounds like a timing issue: IE is busy handling the initial requests and so doesn't get to the later ones before they time out. There isn't anything direct you can do about this, but you could add a short delay between the Launcher calls to keep things from stacking up.

    Note that launching a URI is an untargeted action with no guaranteed behavior. The app handling the URI (if any) will depend on the user's settings, and there is no requirement that the app handle the URI in any particular way. If you're using this only for your own personal use then this may not matter, but for a production app you cannot guarantee that the user will have IE as the default handler.

    --Rob

    • Marked as answer by pumpkinszwan Wednesday, August 27, 2014 1:16 AM
    Wednesday, August 27, 2014 12:30 AM
    Owner

All replies

  • Please refer to the following blog post for more information about this issue: http://srndolha.wordpress.com/2013/10/22/links-dont-work-urls-dont-open-in-windows-8/.

    It seems like you have to modify the registry and reboot to get rid of the issue.

    Tuesday, August 26, 2014 2:25 PM
  • That isn't the issue I'm encountering. I don't even know if my code is *supposed* to work.

    I have no difficulty launchin URLs from any apps at all. The only issue is when I try to initiate multiple URLs from a single command. As soon as IE launches with the first couple of links the rest don't get launched.

    The same behaviour happens on my work PC, my home PC and my Surface 2(RT) tablet all running Windows 8.1.


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

    Wednesday, August 27, 2014 12:15 AM
  • It sounds like a timing issue: IE is busy handling the initial requests and so doesn't get to the later ones before they time out. There isn't anything direct you can do about this, but you could add a short delay between the Launcher calls to keep things from stacking up.

    Note that launching a URI is an untargeted action with no guaranteed behavior. The app handling the URI (if any) will depend on the user's settings, and there is no requirement that the app handle the URI in any particular way. If you're using this only for your own personal use then this may not matter, but for a production app you cannot guarantee that the user will have IE as the default handler.

    --Rob

    • Marked as answer by pumpkinszwan Wednesday, August 27, 2014 1:16 AM
    Wednesday, August 27, 2014 12:30 AM
    Owner
  • Thanks, Rob.

    Adding a small delay seems to work, at least on my work PC (which is launching desktop IE, so presumably this will work on other browsers, which I will test):

    await Task.Delay(TimeSpan.FromSeconds(0.5f));

    between each URL launch is working consistently so far.

    I would like to use this functionality for a released app as I think grouped favourites are sorely missing from Windows RT, but if I can only get it working well enough for personal use then that's fine I suppose!

    thanks


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

    Wednesday, August 27, 2014 1:20 AM