summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Core
diff options
context:
space:
mode:
authordgeller-OUHSC <dgeller@ouhsc.edu>2017-10-03 05:23:32 -0500
committerKangho Hur <kangho.hur@samsung.com>2017-10-23 13:33:58 +0900
commit7accccfc353bda9088d4e9f1be780cc6624d5eca (patch)
treecc33c791b9f2f12957e1697cb3b9e69660365ffc /Xamarin.Forms.Core
parent4d436f71bc9dece7abce4501747eae4292b676bf (diff)
downloadxamarin-forms-7accccfc353bda9088d4e9f1be780cc6624d5eca.tar.gz
xamarin-forms-7accccfc353bda9088d4e9f1be780cc6624d5eca.tar.bz2
xamarin-forms-7accccfc353bda9088d4e9f1be780cc6624d5eca.zip
[Core, Android] Fix to address the elusive 'Sharing violation on path PropertyStore.forms.tmp' (#1075)
* use a semaphor for actual saving piece make reading serialized propertystore readonly to help with collisions. * change over to async Task and await OnStateChanged() method to try and mitigate what might be the race condition causing the ' Sharing violation on path PropertyStore.forms.tmp' error * update Semaphore name * remove private specifier per the style guide * Update docs and add warning suppression for broken mono warning * ... and adding the warning suppression to Release mode, as well. * -add try...finally block so we can guarantee that the semaphore is released if there's an exception while saving the properties. -remove the legacy code that the semaphore replaces * Update docs * Attempting to fix docs * Trying again to get docs to pass
Diffstat (limited to 'Xamarin.Forms.Core')
-rw-r--r--Xamarin.Forms.Core/Application.cs24
1 files changed, 12 insertions, 12 deletions
diff --git a/Xamarin.Forms.Core/Application.cs b/Xamarin.Forms.Core/Application.cs
index 5df8ad6c..b084b52a 100644
--- a/Xamarin.Forms.Core/Application.cs
+++ b/Xamarin.Forms.Core/Application.cs
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
+using System.Threading;
using System.ComponentModel;
using System.Threading.Tasks;
using Xamarin.Forms.Internals;
@@ -15,14 +16,13 @@ namespace Xamarin.Forms
readonly Lazy<PlatformConfigurationRegistry<Application>> _platformConfigurationRegistry;
IAppIndexingProvider _appIndexProvider;
- bool _isSaving;
ReadOnlyCollection<Element> _logicalChildren;
Page _mainPage;
ResourceDictionary _resources;
- bool _saveAgain;
+ static SemaphoreSlim SaveSemaphore = new SemaphoreSlim(1, 1);
protected Application()
{
@@ -304,16 +304,16 @@ namespace Xamarin.Forms
async Task SetPropertiesAsync()
{
- if (_isSaving)
- {
- _saveAgain = true;
- return;
- }
- _isSaving = true;
- await DependencyService.Get<IDeserializer>().SerializePropertiesAsync(Properties);
- if (_saveAgain)
- await DependencyService.Get<IDeserializer>().SerializePropertiesAsync(Properties);
- _isSaving = _saveAgain = false;
+ await SaveSemaphore.WaitAsync();
+ try
+ {
+ await DependencyService.Get<IDeserializer>().SerializePropertiesAsync(Properties);
+ }
+ finally
+ {
+ SaveSemaphore.Release();
+ }
+
}
class NavigationImpl : NavigationProxy