CodeDocu.com

Async Task in Sync Methode

 

How to perform an asynchronous method within a synchronous method in C-

 

Problem: here Async call in Sync event

Async await

            ApplicationData.Current.LocalSettings.Values["Set_CameraNr"]=CameraNr.SelectedIndex ;

            mainpage._mediaCapture = null;

 

            mainpage. InitializeCameraAsync();    

 

 

 

Solution:
Task task

Create a task that calls the method

            Task task = mainpage. InitializeCameraAsync();

            var result = task. Wait(-1);  //wait 1 sek

 

 

Run Async Task in Sync Method

 


Software Entwicklung Stuttgart NĂ¼rtingen
Suche Projekte C#, WPF, Windows App,ASP.Net, vb.Net, WinForms, SQL Server, Access, Excel