public async Task <int> StartUp() { // do we need a new access token if (localSettings.Values["access_token"] == null || localSettings.Values["access_token_expire"] == null || !IsTokenValid(Convert.ToDateTime(localSettings.Values["access_token_expire"].ToString()))) { if (await GetAPIToken() == null) { return(1001); } } // get the device detail SystemDetail systemDetail = await CashGenicAPIService.GetSystem(localSettings.Values["access_token"].ToString()); if (systemDetail == null) { return(1000); } else { // fire new system connected event NewSystemConnectedArgs args = new NewSystemConnectedArgs(); args.system = systemDetail; OnNewSystemConnected(args); _ = Task.Factory.StartNew(() => RunSystem()); } return(0); }
protected virtual void OnNewSystemConnected(NewSystemConnectedArgs e) { EventHandler <NewSystemConnectedArgs> handler = NewSystemConnected; if (handler != null) { handler(this, e); } }