user2424495
user2424495

Reputation: 592

Trouble loading lots of images from web

I am trying to make a simple instagram feed display with WPF. I have a ListView which is bound to an ObservableCollection of image url's retrieved from the Instagram API. For some reason, I can only load the first 10 or so (even though I am trying to bind more). If I try to load lower resolution images, then it seems to work ok. But I'm not talking about massive images anyway (maybe around 100k each).

Here is some example code with a list of hard coded images from instagram. For me, this only loads the first 10, then misses number 11, then loads number 12. I have no idea why.

XAML:

<ListView x:Name="List" ScrollViewer.HorizontalScrollBarVisibility="Disabled" ScrollViewer.VerticalScrollBarVisibility="Hidden" ScrollViewer.CanContentScroll="False">
    <ListView.ItemsPanel>
        <ItemsPanelTemplate>
            <WrapPanel />
        </ItemsPanelTemplate>
    </ListView.ItemsPanel>
    <ListView.ItemTemplate>
        <DataTemplate>
            <Grid Width="250" Height="250" Background="Orange">
                <Image Margin="3" Source="{Binding}" Stretch="Uniform" VerticalAlignment="Center" />
            </Grid>
        </DataTemplate>
    </ListView.ItemTemplate>
</ListView>

Code behind:

List<string> content = new List<string>()
{
    "https://scontent.cdninstagram.com/t51.2885-15/s640x640/sh0.08/e35/23498621_155088151891201_5838888733310451712_n.jpg",      
    "https://scontent.cdninstagram.com/t51.2885-15/s640x640/e15/23421369_1935881716650536_2751759012239245312_n.jpg",
    "https://scontent.cdninstagram.com/t51.2885-15/s640x640/sh0.08/e35/23498900_2424691114423634_1760461413358239744_n.jpg",
    "https://scontent.cdninstagram.com/t51.2885-15/s640x640/sh0.08/e35/23498900_2424691114423634_1760461413358239744_n.jpg",
    "https://scontent.cdninstagram.com/t51.2885-15/s640x640/sh0.08/e35/23347618_263128534210376_920911369891479552_n.jpg",
    "https://scontent.cdninstagram.com/t51.2885-15/s640x640/sh0.08/e35/23421069_1500830839998934_8413516091602501632_n.jpg",
    "https://scontent.cdninstagram.com/t51.2885-15/s640x640/sh0.08/e35/23417348_742804169243503_6556496499100876800_n.jpg",
    "https://scontent.cdninstagram.com/t51.2885-15/s640x640/sh0.08/e35/23347902_2017564028488677_2880579113104441344_n.jpg",
    "https://scontent.cdninstagram.com/t51.2885-15/s640x640/sh0.08/e35/23421331_334537296949861_4296430067371737088_n.jpg",
    "https://scontent.cdninstagram.com/t51.2885-15/s640x640/sh0.08/e35/23421331_334537296949861_4296430067371737088_n.jpg",
    "https://scontent.cdninstagram.com/t51.2885-15/s640x640/sh0.08/e35/23416590_1928818560779337_7080637368553701376_n.jpg",
    "https://scontent.cdninstagram.com/t51.2885-15/sh0.08/e35/p640x640/23421758_491705774540588_6178820534202007552_n.jpg",
    "https://scontent.cdninstagram.com/t51.2885-15/s640x640/sh0.08/e35/23421099_1728264697245367_6448825186568372224_n.jpg",
    "https://scontent.cdninstagram.com/t51.2885-15/s640x640/sh0.08/e35/23416994_133163334113394_1499431022142423040_n.jpg",
    "https://scontent.cdninstagram.com/t51.2885-15/s640x640/sh0.08/e35/23421239_1483718185060885_8134914164545028096_n.jpg",
    "https://scontent.cdninstagram.com/t51.2885-15/s640x640/sh0.08/e35/23280089_1942832749376286_3936575794389712896_n.jpg",
    "https://scontent.cdninstagram.com/t51.2885-15/s640x640/sh0.08/e35/23347674_2006888666245374_7306582919252803584_n.jpg",
    "https://scontent.cdninstagram.com/t51.2885-15/s640x640/sh0.08/e35/23347388_119626992143009_7585283007787827200_n.jpg",
    "https://scontent.cdninstagram.com/t51.2885-15/s640x640/sh0.08/e35/23421865_900301160123071_1326331715420946432_n.jpg",
    "https://scontent.cdninstagram.com/t51.2885-15/s640x640/sh0.08/e35/23421253_148762415872849_1558483017121398784_n.jpg",
    "https://scontent.cdninstagram.com/t51.2885-15/sh0.08/e35/p640x640/23507217_1953269574998281_6711372701967056896_n.jpg",
    "https://scontent.cdninstagram.com/t51.2885-15/sh0.08/e35/p640x640/23507217_1953269574998281_6711372701967056896_n.jpg",
    "https://scontent.cdninstagram.com/t51.2885-15/s640x640/sh0.08/e35/23498098_2009691429314434_8349013357923139584_n.jpg",
    "https://scontent.cdninstagram.com/t51.2885-15/e15/23347679_315062128974030_5091325576380153856_n.jpg",
    "https://scontent.cdninstagram.com/t51.2885-15/sh0.08/e35/p640x640/23421083_1777350415899180_3004366087824343040_n.jpg",
    "https://scontent.cdninstagram.com/t51.2885-15/sh0.08/e35/p640x640/23421083_1777350415899180_3004366087824343040_n.jpg",
    "https://scontent.cdninstagram.com/t51.2885-15/s640x640/sh0.08/e35/23498903_773821689486761_9202713497564086272_n.jpg"
};

List.ItemsSource = content;

Upvotes: 1

Views: 63

Answers (1)

Sean Beanland
Sean Beanland

Reputation: 1118

You're running into the maximum connection limit to the same host for your application.

In your app.config file, you can add the following underneath configuration:

<system.net>
  <connectionManagement>
    <add address="*" maxconnection="1000" />
  </connectionManagement>
</system.net>

You can read more about this here. Obviously you should tailor your entry to what your application actually needs.

Upvotes: 1

Related Questions