473,406 Members | 2,259 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Multithreading and ASP.net

Hai
i am trying to write a multithreading asp.net application
this is the code
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
If Not IsPostBack Then
Try
DisplayLoadingMovie()
StartThread()
Catch ex As Exception

End Try
End If
End Sub

Private Sub GetPlaceHolders()
Try
Thread.Sleep(7000)
Dim strScript As String
strScript = "<script language=javascript>"
strScript &=
"window.parent.fra2.location.href='AfterLoading.as px?Finished=Y';"
strScript &= "</script>"
Response.Write(strScript)
Catch ex As Exception

End Try

End Sub

Private Sub DisplayLoadingMovie()
Dim strScript As String
strScript = "<script language=javascript>"
strScript &=
"window.parent.fra2.location.href='Loading.asp x';"
strScript &= "</script>"
Response.Write(strScript)
End Sub

Private Sub StartThread()
Dim dlgThreadStart As ThreadStart = New ThreadStart(AddressOf
GetPlaceHolders)
Dim workerThread As Thread = New Thread(dlgThreadStart)
workerThread.Start()
End Sub

but wheni try to run the program the GetPlaceHolders method generates
a HttpException saying "Response is not available in this context"
Anyone got any idea how to work around the problem
Jul 21 '05 #1
2 1338
That is because creating another thread, means this thread can't have access
to anything on the page. The original request is still executing - but this
other threat is off on its own, doing work concurrently with the other one.
This is because I can't imagine that asp.net would be able to reconcile all
threads spawned from the original request, and know when it was time to send
the page back.

What is it you are trying to accomplish with multiple threads?

"Shathish" <ns*******@gmail.com> wrote in message
news:e2**************************@posting.google.c om...
Hai
i am trying to write a multithreading asp.net application
this is the code
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
If Not IsPostBack Then
Try
DisplayLoadingMovie()
StartThread()
Catch ex As Exception

End Try
End If
End Sub

Private Sub GetPlaceHolders()
Try
Thread.Sleep(7000)
Dim strScript As String
strScript = "<script language=javascript>"
strScript &=
"window.parent.fra2.location.href='AfterLoading.as px?Finished=Y';"
strScript &= "</script>"
Response.Write(strScript)
Catch ex As Exception

End Try

End Sub

Private Sub DisplayLoadingMovie()
Dim strScript As String
strScript = "<script language=javascript>"
strScript &=
"window.parent.fra2.location.href='Loading.asp x';"
strScript &= "</script>"
Response.Write(strScript)
End Sub

Private Sub StartThread()
Dim dlgThreadStart As ThreadStart = New ThreadStart(AddressOf
GetPlaceHolders)
Dim workerThread As Thread = New Thread(dlgThreadStart)
workerThread.Start()
End Sub

but wheni try to run the program the GetPlaceHolders method generates
a HttpException saying "Response is not available in this context"
Anyone got any idea how to work around the problem

Jul 21 '05 #2
It's likely the request will be over before the thread ends. Remember that
you are not in windows form but are using a request/response model.

It looks like you are just trying here to change something once the document
is loaded. You could use a client side event
(http://msdn.microsoft.com/library/de...uthor/dhtml/re
ference/events/onreadystatechange.asp) and then change your "fra2"
document...

Patrice

--

"Shathish" <ns*******@gmail.com> a écrit dans le message de
news:e2**************************@posting.google.c om...
Hai
i am trying to write a multithreading asp.net application
this is the code
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
If Not IsPostBack Then
Try
DisplayLoadingMovie()
StartThread()
Catch ex As Exception

End Try
End If
End Sub

Private Sub GetPlaceHolders()
Try
Thread.Sleep(7000)
Dim strScript As String
strScript = "<script language=javascript>"
strScript &=
"window.parent.fra2.location.href='AfterLoading.as px?Finished=Y';"
strScript &= "</script>"
Response.Write(strScript)
Catch ex As Exception

End Try

End Sub

Private Sub DisplayLoadingMovie()
Dim strScript As String
strScript = "<script language=javascript>"
strScript &=
"window.parent.fra2.location.href='Loading.asp x';"
strScript &= "</script>"
Response.Write(strScript)
End Sub

Private Sub StartThread()
Dim dlgThreadStart As ThreadStart = New ThreadStart(AddressOf
GetPlaceHolders)
Dim workerThread As Thread = New Thread(dlgThreadStart)
workerThread.Start()
End Sub

but wheni try to run the program the GetPlaceHolders method generates
a HttpException saying "Response is not available in this context"
Anyone got any idea how to work around the problem

Jul 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: dixp | last post by:
I'm new to writing multithreaded apps and I have a design question. I have a winforms app and a class which has a method that does processing which is time intensive. I want the user to be able...
47
by: mihai | last post by:
What does the standard say about those two? Is any assurance that the use of STL is thread safe? Have a nice day, Mihai.
16
by: Robert Zurer | last post by:
Can anyone suggest the best book or part of a book on this subject. I'm looking for an in-depth treatment with examples in C# TIA Robert Zurer robert@zurer.com
5
by: sarge | last post by:
I would like to know how to perform simple multithreading. I had created a simple form to test out if I was multithreading properly, but got buggy results. Sometime the whole thig would lock up...
9
by: tommy | last post by:
hi, i have found a example for multithreading and asp.net http://www.fawcette.com/vsm/2002_11/magazine/features/chester/ i want to speed up my website ... if my website is starting, they...
2
by: Rich | last post by:
Hello, I have set up a multithreading routine in a Test VB.net proj, and it appears to be working OK in debug mode and I am not using synchronization. Multithreading is a new thing for me, and...
55
by: Sam | last post by:
Hi, I have a serious issue using multithreading. A sample application showing my issue can be downloaded here: http://graphicsxp.free.fr/WindowsApplication11.zip The problem is that I need to...
5
by: sandy82 | last post by:
Whats actuallly multithreading is ... and how threading and multithreading differ . Can any1 guide how multithreading is used on the Web .. i mean a practical scenario in which u use...
2
by: Pradnya Patil | last post by:
hi , I am trying to draw ' html div-tag ' on the screen which will resemble a rectangle through vb.net code. I want it to be drawn faster...so I introduced multithreading using Threadpool. I...
7
by: Ray | last post by:
Hello, Greetings! I'm looking for a solid C++ multithreading book. Can you recommend one? I don't think I've seen a multithreading C++ book that everybody thinks is good (like Effective C++ or...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.