C#
C# / 파이어베이스, 파이어스토어 동기 실행, c# firestore firebase Synchronous
캬옹냐옹
2021. 6. 18. 12:09
728x90
FirestoreDb database;//서버 클래스 선언
private void Form_Shown(object sender, EventArgs e)
{
FireBase_Synchronous();
}
//파이어스토어 데이터 싫어오는 메소드 동기 실행 메소드
async void FireBase_Synchronous()
{
bool result;
result = await FireBase_Read();
result = await FireBase_Read();
}
//파이어스토어 데이터 읽어오는 메소드
async Task<bool> FireBase_Read()
{
Query allQuery = database.Collection("collection");
QuerySnapshot allQuerySnapshot = await allQuery.GetSnapshotAsync(); //컬렉션의 모든 문서 가져오기
//Do Something...
return true;
}
비효율적일 수 있지만, 가끔은 비동기 API 제공되는것들을 동기로 실행할 때가 있다.
위에 코드처럼 사용하면 비동기를 동기로 실행 가능하다.
728x90