473,385 Members | 1,766 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,385 software developers and data experts.

Threading Error?

al
Greeting,

I have this sub in a page that runs a thread to change direction of a
page then redirects to a new page(please wait message page)which
checks for a global flag and returns to previous page if true. The
problem when I assign thread priority to highest, it just works like a
dream, otherwise, it produces an error:

----The type System.Web.HttpException
in Assembly System.Web, Version=1.0.5000.0,
Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a is not
marked as serializable-----

Code:
*****In default page:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

Dim NewThread As Thread = New Thread(AddressOf
ChangeDirection)

NewThread.Priority = ThreadPriority.Normal ''''********this
produces and error unless put to highest

NewThread.Start()

Response.Redirect("/Testing/WaitPage.aspx")

End Sub
Public Sub ChangeDirection()

Response.Write("<script>document.dir=""rtl""</script>")

Session("Finished") = True

End Sub
End Class
***********In WaitPage.aspx:

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

If Session("Finished") = False Then

Response.Write("<META HTTP-EQUIV=Refresh CONTENT=""3; URL="">
")
Label1.Text = "Processing. . ."

Else

Label1.Text = "Finished!"
Response.Write("<script>document.location.replace( ""default.aspx"")</>")
End If
End Sub

MTIA,
Grawsha
Nov 18 '05 #1
2 1435
On 4 Apr 2004 12:10:04 -0700, gr*********@yahoo.com (al) typed and posted to
microsoft.public.dotnet.framework.aspnet:

I'm no expert but it might have something to do with the context of the thread.
The fact that it's being called from the ASP.NET worker thread. Being web
based the thread would have to execute as fast as it can so it would not tie up
valuable resources or something to that effect.

My $0.02
Will
Greeting,

I have this sub in a page that runs a thread to change direction of a
page then redirects to a new page(please wait message page)which
checks for a global flag and returns to previous page if true. The
problem when I assign thread priority to highest, it just works like a
dream, otherwise, it produces an error:

----The type System.Web.HttpException
in Assembly System.Web, Version=1.0.5000.0,
Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a is not
marked as serializable-----

Code:
*****In default page:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

Dim NewThread As Thread = New Thread(AddressOf
ChangeDirection)

NewThread.Priority = ThreadPriority.Normal ''''********this
produces and error unless put to highest

NewThread.Start()

Response.Redirect("/Testing/WaitPage.aspx")

End Sub
Public Sub ChangeDirection()

Response.Write("<script>document.dir=""rtl""</script>")

Session("Finished") = True

End Sub
End Class
***********In WaitPage.aspx:

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

If Session("Finished") = False Then

Response.Write("<META HTTP-EQUIV=Refresh CONTENT=""3; URL="">
")
Label1.Text = "Processing. . ."

Else

Label1.Text = "Finished!"
Response.Write("<script>document.location.replace( ""default.aspx"")</>")
End If
End Sub

MTIA,
Grawsha


Nov 18 '05 #2
Nope. OP has violated a sacred threading rule. If it is an NT based system
it could work for a while but it is guaranteed to fail. A thread should not
touch objects owned by the main thread. The response object and the session
objects are owned by the main thread and OP is using it in the child thread.
The easiest way around this is to pass in a reference to the response and
session objects to the child thread. Or, replace the session object with a
static variable assuming that the response.write method doesn't do any real
work. There would need to be synchronization access to this variable
ofcourse.

--
Regards,
Alvin Bruney [ASP.NET MVP]
Got tidbits? Get it here...
http://tinyurl.com/27cok
"William" <wr*********@hot-spam-mail.com> wrote in message
news:4l********************************@4ax.com...
On 4 Apr 2004 12:10:04 -0700, gr*********@yahoo.com (al) typed and posted to microsoft.public.dotnet.framework.aspnet:

I'm no expert but it might have something to do with the context of the thread. The fact that it's being called from the ASP.NET worker thread. Being web
based the thread would have to execute as fast as it can so it would not tie up valuable resources or something to that effect.

My $0.02
Will
Greeting,

I have this sub in a page that runs a thread to change direction of a
page then redirects to a new page(please wait message page)which
checks for a global flag and returns to previous page if true. The
problem when I assign thread priority to highest, it just works like a
dream, otherwise, it produces an error:

----The type System.Web.HttpException
in Assembly System.Web, Version=1.0.5000.0,
Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a is not
marked as serializable-----

Code:
*****In default page:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

Dim NewThread As Thread = New Thread(AddressOf
ChangeDirection)

NewThread.Priority = ThreadPriority.Normal ''''********this
produces and error unless put to highest

NewThread.Start()

Response.Redirect("/Testing/WaitPage.aspx")

End Sub
Public Sub ChangeDirection()

Response.Write("<script>document.dir=""rtl""</script>")

Session("Finished") = True

End Sub
End Class
***********In WaitPage.aspx:

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

If Session("Finished") = False Then

Response.Write("<META HTTP-EQUIV=Refresh CONTENT=""3; URL="">
")
Label1.Text = "Processing. . ."

Else

Label1.Text = "Finished!"
Response.Write("<script>document.location.replace( ""default.aspx"")</>") End If
End Sub

MTIA,
Grawsha

Nov 18 '05 #3

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

Similar topics

0
by: Jacek Trzmiel | last post by:
Hi, I have a problem with using urllib2 with threading module under Cygwin. $ cygcheck -cd cygwin python Cygwin Package Information Package Version cygwin 1.5.5-1...
2
by: Egor Bolonev | last post by:
hi all my program terminates with error i dont know why it tells 'TypeError: run() takes exactly 1 argument (10 given)' =program==================== import os, os.path, threading, sys def...
13
by: RCS | last post by:
I have a UI that needs a couple of threads to do some significant processing on a couple of different forms - and while it's at it, update the UI (set textboxes, fill in listviews). I created a...
2
by: Vjay77 | last post by:
In this code: Private Sub downloadBtn_Click(ByVal sender As Object, ByVal e As System.EventArgs) If Not (Me.downloadUrlTextBox.Text = "") Then Me.outputGroupBox.Enabled = True...
0
by: Pawan Narula via DotNetMonster.com | last post by:
hi all, i'm using VB.NET and trying to code for contact management in a tree. all my contacts r saved in a text file and my C dll reads them one by one and sends to VB callback in a sync mode...
1
by: Gary Kahrau | last post by:
I hope this is a simple question for threading people. VB 2005 Beta2 has a new SerialPort control. I can read the data that I want just fine. However when I try to display the text, I get a...
6
by: hzgt9b | last post by:
Using VS 2003, .NET: I developed a windows application that performs several actions based on an input file. The application displays a progress bar as each action executes. Based on new...
17
by: OlafMeding | last post by:
Below are 2 files that isolate the problem. Note, both programs hang (stop responding) with hyper-threading turned on (a BIOS setting), but work as expected with hyper-threading turned off. ...
2
by: akameswaran | last post by:
Admittedly this problem causes no actual functional issues aside from an occasional error message when the program exits. The error is: Unhandled exception in thread started by Error in...
7
by: Mike P | last post by:
I am trying to write my first program using threading..basically I am moving messages from an Outlook inbox and want to show the user where the process is up to without having to wait until it has...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...

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.