multithreading - silverlight. Wait end async method in sync method -


I have a strange problem. I should wait for the end asynchronous call on the sync function call. In other projects I have successfully used ResetEvents, but it does not seem to work.

  // save some values ​​in the sync call storage. Public static Zero SaveValue (String Key, Object Value, Bull Encrypted) {If (Encrypted) {Encryption = true; Var registrar = new registrar client (); Registrar.nipCompleted + = registrar_encert full; Registrator.EncryptAsync (obj); // Async Thread While (Encrypting) Thread Sleep (10); Return; } ...} static Zero registrar_uncrypted (object sender, encrypted event arrogs e) {if (string.isnaleolacty (fieldto save)) returns; App Appvars = App Current as App; If (apparatus.settings.Comancy (FieldTown)) Appointment. Setting [field tosave] = e. result; Other Apps Settings. Add (Fieldto Save, E. Rezult); Encryption = is incorrect; }  

This method also does not work :( Please help. What happened?

The problem is that all service calls in SL are created on the UI thread, so you have a method sleeping on the UI thread to wait on a callback on the UI thread.

< P> It is impossible to make a truly synchronous call in SL.If you really want to work with things in a synchronous fashion then take a look Take. She cool co-regular patterns of use so that, except as to simulate the synchronous programming call async actual service.


Comments