public void TestSettingsInThread() { DateTime now = DateTime.Now; SyncItem syncItem; System.Action saveAnchor = () => { SyncSettingsBase settings = OutlookSyncSettings.Default; syncItem = OutlookSyncSettings.Default.CalendarSyncItem; syncItem.LastAnchorTime = now; settings.Save(); }; IAsyncResult result = saveAnchor.BeginInvoke(null, null); saveAnchor.EndInvoke(result); System.Threading.Thread.Sleep(100); OutlookSyncSettings.Default.Reload(); Assert.AreEqual(now, OutlookSyncSettings.Default.CalendarSyncItem.LastAnchorTime); now = DateTime.Now; IAsyncResult result2 = saveAnchor.BeginInvoke(null, null); saveAnchor.EndInvoke(result2); System.Threading.Thread.Sleep(100); OutlookSyncSettings.Default.Reload(); Assert.AreEqual(now, OutlookSyncSettings.Default.CalendarSyncItem.LastAnchorTime); }
private void HandleLastAnchorChanged(object sender, AnchorChangedEventArgs e) { ///Apparetly reference to complex type of ApplicationSettingsBase works properly only in the same class and in the same thread ///otherwise, the changes to properties of the complex type can not be detected by ApplicationSettingsBase. ///This function is called in another thread of the Facade. So I need to use propertyName to make the dirty flag work properly. syncItem.LastAnchorTime = e.Time; syncItem.LastAnchor = e.LastAnchor; syncSettings.Save(); AppendStatusText("Last sync: " + syncItem.LastAnchorTime.ToString("yyyy-MM-dd HH:mm:ss")); ShowLastSyncInfo(); }
void UcMultiSyncMain_Load(object sender, EventArgs e) { //Initialize DeviceAddress if (String.IsNullOrEmpty(settings.DeviceAddress) || (settings.DeviceAddress == "FonlowSyncMLClientGuid")) { settings.DeviceAddress = "FonlowSyncMLClient" + Guid.NewGuid().ToString("N"); settings.Save(); } LoadSyncPanels(); }