All-Star
120166 Points
27994 Posts
Moderator
MVP
Oct 14, 2020 06:21 AM|ignatandrei|LINK
TDP please share some sample code which guide me how to add excel thread in dictionary
static ConcurrentDictionary<name, Task<whatever return you have from execution> > myDict
TDP how to return unique id to the front end?
public string CreateExcel(){
string uniqueName = < generate unique name for the user and the excel created>
var t = Task.Run( whatever generates the excel)
myDict.Add(uniqueName, t)
return uniqneName;
}
TDP poll the backend with the unique id to see if the task has been finished
public bool HasTaskFinished(string uniqueName){
// find in myDict if the task for the key uniqueName has finished
All-Star
120166 Points
27994 Posts
Moderator
MVP
Re: How to handle long running operation in mvc Index action like excel file generation
Oct 14, 2020 06:21 AM|ignatandrei|LINK
static ConcurrentDictionary<name, Task<whatever return you have from execution> > myDict
public string CreateExcel(){
string uniqueName = < generate unique name for the user and the excel created>
var t = Task.Run( whatever generates the excel)
myDict.Add(uniqueName, t)
return uniqneName;
}
public bool HasTaskFinished(string uniqueName){
// find in myDict if the task for the key uniqueName has finished
}