private void onTimer(object sender, ElapsedEventArgs e) { _synchronizeInvoke.BeginInvoke(new Action(async() => { if (isConnected() || _checking) { return; } _checking = true; try { string token = HostProperties.GetAccessToken(HostName); ConnectionCheckStatus result = await ConnectionChecker.CheckConnectionAsync(HostName, token); if (!isConnected() && result == ConnectionCheckStatus.OK) { // isConnected() check is needed because connection has been probably already restored // while we awaited for a CheckConnectionAsync() result Trace.TraceInformation("[GitLabInstance] ConnectionChecker.CheckConnection() returned OK"); onConnectionRestored(); } } finally { _checking = false; } }), null); }
async private Task <GitLabVersion> getVersionAsync() { string token = HostProperties.GetAccessToken(HostName); using (GitLabTaskRunner client = new GitLabTaskRunner(HostName, token)) { try { return((GitLabVersion)(await client.RunAsync(async(gl) => await gl.Version.LoadTaskAsync()))); } catch (GitLabSharpException ex) { ExceptionHandlers.Handle("Cannot obtain GitLab server version", ex); } catch (GitLabRequestException ex) { ExceptionHandlers.Handle("Cannot obtain GitLab server version", ex); } catch (GitLabTaskRunnerCancelled) { } return(null); } }