Here i am sharing a sample code
private async void button1_Click(object sender, EventArgs e)
{
bool retvalue = false;
var periodTimeSpan = TimeSpan.FromSeconds(10);
var task1 = SimulateJob();
var task2 = Task.Delay(periodTimeSpan);
await Task.WhenAll(task1, task2);
retvalue = (bool) task1.Result;
}
private Task<bool> SimulateJob()
{
bool status = false;
Task.Delay(10000);
status = true;
return Task.FromResult(status);
}
please run the code and understand that SimulateJob() function getting called twice.
in real code SimulateJob() function load multiple big excel file. i saw when this line execute var task1 = SimulateJob(); then my routine load all those big files which is my problem. i want that when this line would execute await Task.WhenAll(task1, task2); then my SimulateJob function should load those big excel file. so tell me what i need to change in my code example.
please help me to handle this situation. thanks