Hi Jun,
You can check the Task.IsCompleted property and implement it in a way that suits your needs.
Here’s a quick and simple example:
static async Task CheckTask() {
Task task = Task.Delay(5000); // Example background task
Console.WriteLine("Task started. Waiting for completion...");
while (!task.IsCompleted)
{
Console.WriteLine($"Task status: {task.Status}");
await Task.Delay(1000); // Wait for 1 second before checking again
}
Console.WriteLine(“Task completed.”);
}
HTH,
Alaa
Please login first to submit.