Loading, please wait...

A to Z Full Forms and Acronyms

Xamarin.Forms - Network Speed Monitor

In this article, you will learn how to monitor you network speed in Xamarin.Forms.

Xamarin.Forms - Network Speed Monitor


Xamarin.Forms code runs on multiple platforms - each of which has its own filesystem. This means that reading and writing files is most easily done using the native file APIs on each platform. Alternatively, embedded resources are a simpler solution to distribute data files with an app.


  • Visual Studio 2017 or later (Windows or Mac)

Setting up a Xamarin.Forms Project

Start by creating a new Xamarin.Forms project. You wíll learn more by going through the steps yourself.

Create a new or existing Xamarin forms(.Net standard) Project. With Android and iOS Platform.

Network Monitor

Now, create a network that helps the class to check network connectivity in xamarin.froms.


public class NetworkHelper

        public async Task<string> CheckInternetSpeed()
            DateTime dt1 = DateTime.Now;
            string internetSpeed;
                var client = new HttpClient();
                byte[] data = await client.GetByteArrayAsync("http://xamarinmonkeys.blogspot.com/");
                DateTime dt2 = DateTime.Now;                Console.WriteLine("ConnectionSpeed: DataSize (kb) " + data.Length / 1024);
                Console.WriteLine("ConnectionSpeed: ElapsedTime (secs) " + (dt2 - dt1).TotalSeconds);
                internetSpeed = "ConnectionSpeed: (kb/s) " + Math.Round((data.Length / 1024) / (dt2 - dt1).TotalSeconds, 2);
            catch (Exception ex)
                internetSpeed = "ConnectionSpeed:Unknown Exception-" + ex.Message;
            return internetSpeed;

Consuming Network helper

Here, you will call the Network helper class and you will get the network speed.


<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"

    <StackLayout HorizontalOptions="Center" VerticalOptions="Start" Margin="0,150,0,0">
        <Label FontSize="Large" Text="Xamarin Monkeys"/>
        <Button Text="Check" Clicked="Button_Clicked"></Button>


Here I show the result in a toast.


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms;
using Xamarin.Essentials;
using System.Net.Http;
namespace NetworkPOC
    // Learn more about making custom code visible in the Xamarin.Forms previewer
    // by visiting https://aka.ms/xamarinforms-previewer
    public partial class MainPage : ContentPage
        public MainPage()

        private async void Button_Clicked(object sender, EventArgs e)

            if (current == NetworkAccess.Internet)
                var speed=await CheckInternetSpeed();

                DependencyService.Get<IToast>().ShowToast("No Internet Connection");


I hope you have understood you will learn how to check network speed in Xamarin.Forms.

Thanks for reading. Please share your comments and feedback.
Happy Coding :)

A to Z Full Forms and Acronyms