Understanding Xamarin's iOS Timer Monitoring Image Display

Asked 4 months ago, Updated 4 months ago, 13 views


in seconds on the IIS server side I'm trying to display 1 to 7 images on Xamarin's iOS.
I was able to see Android, but
iOS doesn't work for some reason.
The methodology is simple, and after monitoring with a timer
I feel like I'm going to look at the HTTP address in the server.
The Android version will display it without any problems.
For some reason, it doesn't show up when it comes to iOS.
Is there any reason?

Thank you for your cooperation.

using System.Timers;
using Xamarin.Forms;

namespaceAssd1Tab.Views
{
    public partial class ReceiveDataPageiOS:ContentPage
    {
        /// <summary>Control for Timer</summary>
        public Timer Timer 1 { get; set; } = null;
        
        public ReceiveDataPageiOS()
        {
            InitializeComponent();
            Timer1 = new Timer();
            Timer 1.Interval = 1000;
            Timer 1.Start();
            Timer1.Elapped+=newElappedEventHandler (OnTimerEvent);
        }

        /// <summary>
        /// Timer Events
        /// </summary>
        /// <param name="source"></param>
        /// <param name="e"></param>
        private void OnTimerEvent(object source, ElapsedEventArgse)
        {
            Image1.Source="http://192.168.0.10/Pic1/Pic0.Jpeg";
            Image2.Source="http://192.168.0.10/Pic1/Pic1.Jpeg";
            Image3.Source="http://192.168.0.10/Pic1/Pic2.Jpeg";
            Image4.Source="http://192.168.0.10/Pic1/Pic3.Jpeg";
            Image5.Source="http://192.168.0.10/Pic1/Pic4.Jpeg";
            Image6.Source="http://192.168.0.10/Pic1/Pic5.Jpeg";
            Image7.Source="http://192.168.0.10/Pic1/Pic6.Jpeg";
            Image8.Source="http://192.168.0.10/Pic1/Pic7.Jpeg";
            
        }

        /// <summary>
        /// Content Load Event (event on this form call)
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ContentPage_Appearing (System.Object sender, System.EventArgse)
        {
            Image1.Source="http://192.168.0.10/Pic1/Pic0.Jpeg";
        }

        /// <summary>
        /// Content unload event (event when this form is erased)
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ContentPage_Desappearing (System.Object sender, System.EventArgse)
        {
        }
        private void ContentPage_LayoutChanged (object sender, System.EventArgse)
        {

        }
    }
}


<?xml version="1.0" encoding="UTF-8"?>
<ContentPage
    xmlns="http://xamarin.com/schemas/2014/forms"
    xmlns: x="http://schemas.microsoft.com/winfx/2009/xaml"
    x: Class="Assd1Tab.Views.ReceiveDataPageiOS"
    Appearing="ContentPage_Appearing"Disappearing="ContentPage_Desappearing" LayoutChanged="ContentPage_LayoutChanged">
    <ContentPage.Content>
        <StackLayout Padding="0,0,0,0" VerticalOptions="Center">
            <Gridx: Name="ReciveGrid" RowSpacing="0" ColumnSpacing="0">
                <Grid.RowDefinitions>
                    <RowDefinition Height="100"/>
                    <RowDefinition Height="100"/>
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition/>
                    <ColumnDefinition/>
                    <ColumnDefinition/>
                    <ColumnDefinition/>
                    <ColumnDefinition/>
                    <ColumnDefinition/>
                    <ColumnDefinition/>
                    <ColumnDefinition/>
                </Grid.ColumnDefinitions>
                <Image x: Name="Image 1" Grid.Column="1" Grid.Row="0"/>
                <Image x: Name="Image2" Grid.Column="2" Grid.Row="0"/>
                <Image x: Name="Image 3" Grid.Column="3" Grid.Row="0"/>
                <Image x: Name="Image 4" Grid.Column="4" Grid.Row="0"/>
                <Image x: Name="Image 5" Grid.Column="5" Grid.Row="0"/>
                <Image x: Name="Image 6" Grid.Column="6" Grid.Row="0"/>
                <Image x: Name="Image 7" Grid.Column="7" Grid.Row="0"/>
                <Image x: Name="Image8" Grid.Column="8" Grid.Row="0"/>
            </Grid>
        </StackLayout>
    </ContentPage.Content>
</ContentPage>

ios xamarin

2022-09-30 11:38

1 Answers

I edited the Timer event part as follows, and the iOS version worked.

private void OnTimerEvent(object source, ElapsedEventArgse)
{
    Device.BeginInvokeOnMainThread()=>
    {
        Image1.Source="http://192.168.0.10/Pic1/Pic0.Jpeg";
        Image2.Source="http://192.168.0.10/Pic1/Pic1.Jpeg";
        Image3.Source="http://192.168.0.10/Pic1/Pic2.Jpeg";
        Image4.Source="http://192.168.0.10/Pic1/Pic3.Jpeg";
        Image5.Source="http://192.168.0.10/Pic1/Pic4.Jpeg";
        Image6.Source="http://192.168.0.10/Pic1/Pic5.Jpeg";
        Image7.Source="http://192.168.0.10/Pic1/Pic6.Jpeg";
        Image8.Source="http://192.168.0.10/Pic1/Pic7.Jpeg";
    });
}


2022-09-30 11:38

If you have any answers or tips


© 2023 OneMinuteCode. All rights reserved.