diff --git a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Stubs/OutlookWrappers/StoresWrapper.cs b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Stubs/OutlookWrappers/StoresWrapper.cs index 386952c..58dfd93 100644 --- a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Stubs/OutlookWrappers/StoresWrapper.cs +++ b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Stubs/OutlookWrappers/StoresWrapper.cs @@ -160,9 +160,12 @@ namespace Acacia.Stubs.OutlookWrappers foreach (KeyValuePair remove in removed) { Logger.Instance.Debug(this, "Account removed: {0} - {1}", remove.Value, remove.Key); - _accountsBySmtp.Remove(remove.Value.SmtpAddress); _accountsByStoreId.Remove(remove.Key); - OnAccountRemoved(remove.Value); + if (remove.Value != null) + { + _accountsBySmtp.Remove(remove.Value.SmtpAddress); + OnAccountRemoved(remove.Value); + } } } catch (System.Exception e) diff --git a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/ZPush/ZPushWatcher.cs b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/ZPush/ZPushWatcher.cs index 3e19e51..c8afd5b 100644 --- a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/ZPush/ZPushWatcher.cs +++ b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/ZPush/ZPushWatcher.cs @@ -21,6 +21,7 @@ using Acacia.Utils; using Acacia.ZPush.Connect; using Microsoft.Win32; using System; +using System.Collections.Concurrent; using System.Collections.Generic; using System.Linq; using System.Text; @@ -227,7 +228,7 @@ namespace Acacia.ZPush } } - private readonly Dictionary _folderWatchers = new Dictionary(); + private readonly ConcurrentDictionary _folderWatchers = new ConcurrentDictionary(); private ZPushFolder _rootFolder; private void HandleFolderWatchers(ZPushAccount account) @@ -245,7 +246,7 @@ namespace Acacia.ZPush if (!_folderWatchers.TryGetValue(folder, out watcher)) { watcher = new FolderWatcher(); - _folderWatchers.Add(folder, watcher); + _folderWatchers.TryAdd(folder, watcher); } watcher.Discovered += handler;