When I run code to insert data in a Google Firestore database, the database gets updated, but the application just freezes as if database operation is not completed.
But when I add a 1000ms timeout in wait, then my code works properly.
private async Task AddData1(string project)
{
FirestoreDb db = FirestoreDb.Create(project);
DocumentReference docRef = db.Collection("employees").Document("100250");
Dictionary<string, object> user = new Dictionary<string, object>
{
{"Name","nakshatra"},
{"Age","7"},
{"Domicile","Himanchal"}
};
label1.Text += "Inserting data to firestore database";
WriteResult x= await docRef.SetAsync(user);
Console.WriteLine(" Data added for employee no 100242");
label1.Text += "Data Inserted successfully";
}
and the function call is
AddData1("testproj1-7d81b").Wait(); //app freezes
AddData1("testproj1-7d81b").Wait(1000); // app works fine
After running the code, it should insert the data in a Firestore database. Then should print "Data Inserted successfully";
But instead the app freezes.