Hello guys. I've got strange issue. I want wait end async call at sync function call. At other projects I successfully use ResetEvents, but in sl it don't seem to be working.
//Sync call save some value in storage
public static void SaveValue(string key, object value, bool encrypted)
{
if (encrypted)
{
isEncrypting = true;
var Registrator = new RegistratorClient();
Registrator.EncryptCompleted +=Registrator_EncryptCompleted;
Registrator.EncryptAsync(obj); //async call
while (isEncrypting)
Thread.Sleep(10);
return;
}
...
}
static void Registrator_EncryptCompleted(object sender, EncryptCompletedEventArgs e)
{
if (String.IsNullOrEmpty(fieldToSave))
return;
App Appvars = Application.Current as App;
if (Appvars.Settings.Contains(fieldToSave))
Appvars.Settings[fieldToSave] = e.Result;
else
Appvars.Settings.Add(fieldToSave, e.Result);
isEncrypting = false;
}
This method isn't work too:( Help please. What's wrong?