Click here to Skip to main content
15,886,570 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
When I Perform an action in Index View
Students data has to be read from database at the same time read subjects for each Student in another function and at the same time binding subjects to Index View
, i am expecting parallel execution and result
C#
public class tbl_Student
{
    public string Name {get;set;};
    public string HallTicket {get;set;}
}

public class tbl_Subjects
{
    public string HallTicket {get;set;};
    
    public string Subject1 {get;set;}
    public string Subject2 {get;set;}
}

[HttpPost]
public ActionResult Index()
{
    Go();

    return View();
}

public async static void Go()
{
    List<tbl_student> objstudents= await GetStudentData();

    foreach (var onestudent in objstudents )
    {
        List<tbl_subjects> objsubjects = GetSubjectsForHTNO (onestudent );
    }

    private static Task<list><tbl_student>>GetStudentData()
    {
        List<tbl_student> objStudetns=...
        // Here i am fetching Data
        return objStudents
    }
    public static List<tbl_subjects> GetSubjectsForHTNO(tbl_Student objStudent)
    {
        List<tbl_subjects> objsubjects= ...
        
        return objsubjects
    }

    // here i need to bind objsubjects to Index View only
    // How Shoud I
}

Thank you
Posted
v2
Comments
Dave Kreskowiak 2-May-15 9:23am    
You never described what the problem was, nor asked a question.

1 solution

You is missing a close bracket in the code.

See http://www.dotnetperls.com/async for more info.

This Async, Await stuff to me who uses 3.5 seems like code candy and i cannot see what it offer me above using a thread and reading the running state.

maybe it has something in it for cross threading or something better to abort threads (We never do that do we now)

I could do with a lesson here myself because i am told we should be using processes for long running operations and that means writing dll's to do the procesing and then having to hook the results back up with the client side of the program.

Giving birth to a process is slow as is marshaling the results but at least you can kill it dead unlike threads that are stuck and waiting on a socket to reply.

would be nice to do

C#
Process P=Process.OnTheFly("{OpenFile();Read();Return 123;}");
P.Start();
Thread.sleep(5000);
if (P.State=="Running")
  P.Kill();
else
  {
   int Num=P.Value
   P.Close();
  }
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900