private void OnListTimer() { if (ListTask == null || !ListTask.Wait(0, ListTaskCancellation.Token)) { return; } ListTimer.Change(Timeout.InfiniteTimeSpan, Timeout.InfiniteTimeSpan); IsListing = false; IsListingCancelable = true; CalendarList?Result = ListTaskCancellation.IsCancellationRequested ? null : ListTask.Result; ListTask = null; ParseCalendarListResult(Result); }
private void StartUpdatingCalendarList() { SharedCalendarEntryList.Clear(); if (ApplicationName.Length == 0) { return; } if (CredentialToken == null) { ObtainCredentialToken(false); } if (CredentialToken == null) { return; } try { // Create Google Calendar API service. using CalendarService service = new CalendarService(new BaseClientService.Initializer() { HttpClientInitializer = CredentialToken, ApplicationName = ApplicationName }); // Define parameters of requestCalendarList. CalendarListResource.ListRequest requestCalendarList = service.CalendarList.List(); requestCalendarList.ShowDeleted = false; requestCalendarList.MaxResults = 10; // List events. ListTaskCancellation = new CancellationTokenSource(); ListTask = requestCalendarList.ExecuteAsync(ListTaskCancellation.Token); IsListing = true; IsListingCancelable = true; ListTimer.Change(ListTimerStart, ListTimerInterval); } catch { } }