N
Nitin J Jain
Guest
I am consuming a our .net core (3.1) class library. This library have some async method. I want to call this async method from my method i.e. Synchronous in nature.
public class MyClass {
private myLibraryClass _myLibClass;
public MyClass(){
_myLibClass = new MyLibraryClass();
}
// This is sync method getting called from button click event.
public void GetData(){
string data = _myLibClass.GetDataAsync();
// Some more logic that depends on "data" return from GetDataAsync() method.
ProcessData(data);
}
}
As per some research Task.Wait() and Task.Result is not the best practice to wait for the async method execution completion. Please suggest the way.
Continue reading...
public class MyClass {
private myLibraryClass _myLibClass;
public MyClass(){
_myLibClass = new MyLibraryClass();
}
// This is sync method getting called from button click event.
public void GetData(){
string data = _myLibClass.GetDataAsync();
// Some more logic that depends on "data" return from GetDataAsync() method.
ProcessData(data);
}
}
As per some research Task.Wait() and Task.Result is not the best practice to wait for the async method execution completion. Please suggest the way.
Continue reading...