I start a parallel thread inside a control with the following code:
Private Sub StartParallelPr oc(ByVal Command As SqlClient.SqlCo mmand)
Dim T As New Threading.Threa d(AddressOf ParallelProc)
Command.Paramet ers("MyID").Val ue = Guid.NewGuid.To String
System.Web.Http Context.Current .Session("ID") = Command
T.Start()
End Sub
Private Sub ParallelProc()
Dim Command As SqlClient.SqlCo mmand = DirectCast(Syst em.Web.HttpCont ext.Current.Ses sion("ID") ,SqlClient.SqlC ommand )
Command.Execute NonQuery()
'other code...
End Sub
The StartParallelPr oc procedure is called from the CreateChildCont rols of the Control.
Now, inside the ParallelProc, in the new thread, the System.Web.Http Context.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 StartParallelPr oc(ByVal Command As SqlClient.SqlCo mmand)
Dim T As New Threading.Threa d(AddressOf ParallelProc)
Command.Paramet ers("MyID").Val ue = Guid.NewGuid.To String
System.Web.Http Context.Current .Session("ID") = Command
T.Start()
End Sub
Private Sub ParallelProc()
Dim Command As SqlClient.SqlCo mmand = DirectCast(Syst em.Web.HttpCont ext.Current.Ses sion("ID") ,SqlClient.SqlC ommand )
Command.Execute NonQuery()
'other code...
End Sub
The StartParallelPr oc procedure is called from the CreateChildCont rols of the Control.
Now, inside the ParallelProc, in the new thread, the System.Web.Http Context.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?)
Comment