Well, there's a couple things here.
The first, and the one that should be addressed immediately, is that your code is wide open for SQL injection. You'll want to do some validation on todaysaction.TaskText before passing it to GetGraphData().
Now as to your issue, the main problem is that you're not actually setting things up for asynchronous operation. Yes, the Task object is used as a part of the framework, but it doesn't work in quite the way that you think it does. The nice thing about tasks is that you can pass them around. It doesn't matter what object they ultimately execute on, they will use the context of the original object (they are a reference type).
You're also not using async and await, which are the keywords that let the compiler know to expect upcoming async operations.
Also, I'm not sure which SQL access library you're using there, but it it's entirely possible that it's not being cleaned up. You might be hitting a sql connection cap (if the CommandRunner is disposable, I would wrap it with using()).
Now, all that in mind, the code is not currently configured to run async. MS has a good primer at:
https://msdn.microsoft.com/en-us/library/hh191443.aspx[
^]
Assuming the MVC Action calls Method 1:
public Task<ConcurrentBag<GraphData>> GetGraphData(int UserId, string currentdate)
{
TeamPerformance teamperformance = new TeamPerformance();
return teamperformance.GetGraphData(UserId, currentdate);
}
Assuming that Method 2 is teamperformance.GetGraphData() and Method 3 is DataAccess.DataAccess.GetGraphData():
public Task<ConcurrentBag<GraphData>> GetGraphData(int UserId, string currentdate)
{
return DataAccess.DataAccess.GetGraphData(UserId, currentdate);
}
[HttpPost]
public async JsonResult GetBarChartDetails(Actiontext todaysaction)
{
ConcurrentBag<GraphData> listBarChart;
string actualdate = todaysaction.TaskText;
int UserAdminId = Convert.ToInt32(Session["UserId"]);
MembershipRepository.Service.ServiceRepository serviceRepository = new MembershipRepository.Service.ServiceRepository();
try
{
listBarChart = await serviceRepository.GetGraphData(UserAdminId, actualdate);
}
catch(ex)
{
}
return Json(listBarChart, JsonRequestBehavior.AllowGet);
}