C
Claudio Biagioli
I start a parallel thread inside a control with the following code:
Private Sub StartParallelProc(ByVal Command As SqlClient.SqlCommand)
Dim T As New Threading.Thread(AddressOf ParallelProc)
Command.Parameters("MyID").Value = Guid.NewGuid.ToString
System.Web.HttpContext.Current.Session("ID") = Command
T.Start()
End Sub
Private Sub ParallelProc()
Dim Command As SqlClient.SqlCommand = DirectCast(System.Web.HttpContext.Current.Session("ID") ,SqlClient.SqlCommand )
Command.ExecuteNonQuery()
'other code...
End Sub
The StartParallelProc procedure is called from the CreateChildControls of the Control.
Now, inside the ParallelProc, in the new thread, the System.Web.HttpContext.Current property appears to be Nothing.
Also if I try to access Page.Session property I have an error.
This does not happen if I have the same code inside a page instead of inside a control.
Any Idea, solution?
Do you know alternative ways to communicate between the threads (to pass the ID property and other info?)
Private Sub StartParallelProc(ByVal Command As SqlClient.SqlCommand)
Dim T As New Threading.Thread(AddressOf ParallelProc)
Command.Parameters("MyID").Value = Guid.NewGuid.ToString
System.Web.HttpContext.Current.Session("ID") = Command
T.Start()
End Sub
Private Sub ParallelProc()
Dim Command As SqlClient.SqlCommand = DirectCast(System.Web.HttpContext.Current.Session("ID") ,SqlClient.SqlCommand )
Command.ExecuteNonQuery()
'other code...
End Sub
The StartParallelProc procedure is called from the CreateChildControls of the Control.
Now, inside the ParallelProc, in the new thread, the System.Web.HttpContext.Current property appears to be Nothing.
Also if I try to access Page.Session property I have an error.
This does not happen if I have the same code inside a page instead of inside a control.
Any Idea, solution?
Do you know alternative ways to communicate between the threads (to pass the ID property and other info?)