Skip to content

Latest commit

 

History

History
38 lines (27 loc) · 1.23 KB

11_Check_Services_Status.md

File metadata and controls

38 lines (27 loc) · 1.23 KB

Example 11 - Check the running of services (Data,Com,Core)

After starting the IoT device, the first step is to check the service you want to access.

var com = await Services.ComIsInitialized();
var data = await Services.DataIsInitialized();
var core = await Services.CoreIsInitialized();

Core example:

In the example below, check that the Data and Com service is already available.

 .....

 public async void Run(IBackgroundTaskInstance taskInstance)
 {
      _Deferral = taskInstance.GetDeferral();

      EventLogging.Initialize();
      EventLogging.AddLogMessage(MessageType.Info, this.GetType().Name + " - " + ServiceDisplayName + " - " + "Start initializing...");

      bool exit = false;
      while (exit == false)
      {
          var com = await Services.ComIsInitialized();
          var data = await Services.DataIsInitialized();
          if (com.Initialized == true && data.Initialized==true)
          {
              exit = true;
          }
          await Task.Delay(5000);
      }

     //.....

     EventLogging.AddLogMessage(MessageType.Info, this.GetType().Name + " - " + ServiceDisplayName + " - " + "Finished initialization.");
}