468,549 Members | 2,309 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,549 developers. It's quick & easy.

HttpContext is Nothing in new Thread inside a control

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?)

Nov 17 '05 #1
2 3039
As far as i know the only way to do it is to pass the Context as
parameter to the thread. let me know if you need a sample.

Natty Gur, CTO
Dao2Com Ltd.
28th Baruch Hirsch st. Bnei-Brak
Israel , 51114

Phone Numbers:
Office: +972-(0)3-5786668
Fax: +972-(0)3-5703475
Mobile: +972-(0)58-888377

Know the overall picture
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 17 '05 #2
I actually would like a sample of passing a parameter to a thread. I know
it it possible, but the only thing I could find was NOT passing it to the
thread.

Thanks,

bill

"Natty Gur" <na***@dao2com.com> wrote in message
news:eW**************@TK2MSFTNGP11.phx.gbl...
As far as i know the only way to do it is to pass the Context as
parameter to the thread. let me know if you need a sample.

Natty Gur, CTO
Dao2Com Ltd.
28th Baruch Hirsch st. Bnei-Brak
Israel , 51114

Phone Numbers:
Office: +972-(0)3-5786668
Fax: +972-(0)3-5703475
Mobile: +972-(0)58-888377

Know the overall picture
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by John | last post: by
2 posts views Thread by Francois Malgreve | last post: by
5 posts views Thread by coollzh | last post: by
4 posts views Thread by Makarand Keer | last post: by
2 posts views Thread by kplkumar | last post: by
6 posts views Thread by =?Utf-8?B?Q2h1Y2sgUA==?= | last post: by
2 posts views Thread by =?Utf-8?B?YWxiZXJ0b3Nvcmlh?= | last post: by
3 posts views Thread by Madhur | last post: by
reply views Thread by NPC403 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.