473,513 Members | 2,409 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1441
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
1513
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
2954
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
371
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
2231
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
2933
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
1078
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
1885
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
6389
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
2055
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
2352
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
7175
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
7391
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
7553
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...
1
7120
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
7542
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
4754
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3235
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1609
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
809
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.