10 Rules for Building a Windows Phone App: Listing 1.

Checking network availability.

public class Environment 
{
  public Environment()
  {
  myDispatcherTimer.Interval = new TimeSpan(0, 0, 0, 2, 0); // check every 2 Seconds 
  myDispatcherTimer.Tick += new EventHandler(CheckNetwork);
  myDispatcherTimer.Start();
}

public void CheckNetwork(object o, EventArgs sender)
{
  if (NetworkInterface.GetIsNetworkAvailable())
    return System.Windows.Visibility.Visible;
  else
    return System.Windows.Visibility.Collapsed;

  RaisePropertyChanged("IsNetworkAvailable");
  }

  public System.Windows.Visibility IsNetworkAvailable
{
  get
  {


    return _IsNetworkAvailable;
  }
  set
  {
    _IsNetworkAvailable = value;
    RaisePropertyChanged("IsNetworkAvailable");
  }
 }
}
  }
  }

About the Author

Max Zilberman is an architect evangelist at Microsoft on the Developer andPlatform Evangelism team and is available at [email protected].

comments powered by Disqus

Featured

  • Java on Visual Studio Code Going Cloud Native

    Cloud-native development figures prominently in a new roadmap published by Microsoft's Java on Visual Studio Code dev team.

  • Speed Lines Graphic

    Quantum-Inspired Annealing Using C# or Python

    Dr. James McCaffrey of Microsoft Research explains a new idea that slightly modifies standard simulated annealing by borrowing ideas from quantum mechanics.

  • Visual Studio 2022 v17.1 Preview 3 Improves Web Tools

    Microsoft quietly shipped Visual Studio 2022 v17.1 Preview 3 with enhancements to web tools.

  • Progress Telerik Adds 20-Plus Components for Blazor, .NET MAUI and WinUI

    The R1 2022 release of Progress Telerik development tooling adds more than 20 new components to the Blazor, .NET MAUI and WinUI offerings.

Upcoming Events