private void CheckSyncStalled(ZPushAccount account) { if (!CheckSyncStall) { return; } // Check the inbox folder using (IFolder inbox = account.Account.Store.GetDefaultFolder(DefaultFolder.Inbox)) { string syncId = (string)inbox.GetProperty(OutlookConstants.PR_ZPUSH_SYNC_ID); // If it's syncing, it's not stalled if (syncId != null && syncId != "0") { return; } SyncSession sync = account.GetFeatureData <SyncSession>(this, null); // If the last sync time hasn't changed, it hasn't actually synced yet if (sync.LastSyncTime != null && _syncStallLastSyncTime == sync.LastSyncTime) { return; } _syncStallLastSyncTime = sync.LastSyncTime; // Get the sync state string folderId = (string)inbox.GetProperty(OutlookConstants.PR_ZPUSH_FOLDER_ID); if (folderId != null) { // Check if the folder has synced. In that case, it's not stalled. if (sync.HasFolderSynced(folderId)) { return; } } } // It is not syncing, check for a stall if (_syncStallStarted == null) { _syncStallStarted = DateTime.Now; } else if (_syncStallStarted.Value.Add(CheckSyncStallPeriod) <= DateTime.Now) { // We have a stall if (!_syncStallAsked) { // Set the flag to prevent asking again _syncStallAsked = true; // And alert the user SyncStalled(account); } } }