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

  • Poisson Regression Using C#

    Dr. James McCaffrey from Microsoft Research presents a complete end-to-end demo of Poisson regression, where the goal is to predict a count of things arriving, such as the number of telephone calls received in a 10-minute interval at a call center. When your source data is close to mathematically Poisson distributed, Poisson regression is simple and effective.

  • Cloud-Focused .NET Aspire 9.1 Released

    Along with .NET 10 Preview 1, Microsoft released.NET Aspire 9.1, the latest update to its opinionated, cloud-ready stack for building resilient, observable, and configurable cloud-native applications with .NET.

  • Microsoft Ships First .NET 10 Preview

    Microsoft shipped .NET 10 Preview 1, introducing a raft of improvements and fixes across performance, libraries, and the developer experience.

  • C# Dev Kit Previews .NET Aspire Orchestration

    Microsoft's dev team has been busy updating the C# Dev Kit, a Visual Studio Code extension that enhances the C# development experience by providing tools for managing, debugging, and editing C# projects.

  • Hands On: New VS Code Insiders Build Creates Web Page from Image in Seconds

    New Vision support with GitHub Copilot in the latest Visual Studio Code Insiders build takes a user-supplied mockup image and creates a web page from it in seconds, handling all the HTML and CSS.

Subscribe on YouTube

Upcoming Training Events