Tuesday, March 13, 2012

Thread was being aborted

I've started getting "Thread was being aborted" errors. This errormessage
has me puzzled. I'm using the same very simple approach throughout the
application, and it works elsewhere:
-- my aspx form declares an instance of a data-layer class with form-level
scope
Protected WithEvents MyDataLayer as DataLayer
-- and a new instance of the class is created in Page_Load:
MyDataLayer = New DataLayer
AddHandler MyDataLayer.Success, AddressOf OnSuccess
-- on the aspx form, a Save button onclick eventhandler invokes a method in
the datalayer class
MyDataLayer.DoSomething()
-- the data layer's DoSomething() method executes a stored procedure against
SQL Server and raises either a Success or Failure event
RaiseEvent Success(args as DataLayer.SuccessArgs)
-- a subroutines on the aspx form listens for the success event:
Private Sub OnSuccess(args as DataLayer.SuccessArgs)
Try
'// on Success, we want to go to another page;
'// none of the following alternatives works:
Response.Redirect("SomeOtherPage.aspx", False)
Response.Redirect("SomeOtherPage.aspx", True)
Server.Transfer("SomeOtherPage.aspx", False)
Server.Transfer("SomeOtherPage.aspx", True)
Catch ex as Exception
'// always thread was being aborted error
End Try
End Sub
How do I fix this? Is it a timing issue not under programmer's control?
Thanks
K.Hi Josef:
ThreadAbortException is the expected behavior for
Response.Redirect(url, true) [1]. Are you still getting an abort when
passing false as the second parameter?
[1] http://support.microsoft.com/kb/312629/EN-US/
Scott
http://www.OdeToCode.com/blogs/scott/
On Sun, 22 May 2005 12:48:10 -0400, "Josef K." <josefk@.spamcastle.org>
wrote:

>I've started getting "Thread was being aborted" errors. This errormessage
>has me puzzled. I'm using the same very simple approach throughout the
>application, and it works elsewhere:
>-- my aspx form declares an instance of a data-layer class with form-level
>scope
>Protected WithEvents MyDataLayer as DataLayer
>-- and a new instance of the class is created in Page_Load:
>MyDataLayer = New DataLayer
>AddHandler MyDataLayer.Success, AddressOf OnSuccess
>-- on the aspx form, a Save button onclick eventhandler invokes a method in
>the datalayer class
>MyDataLayer.DoSomething()
>-- the data layer's DoSomething() method executes a stored procedure agains
t
>SQL Server and raises either a Success or Failure event
>RaiseEvent Success(args as DataLayer.SuccessArgs)
>-- a subroutines on the aspx form listens for the success event:
>Private Sub OnSuccess(args as DataLayer.SuccessArgs)
> Try
> '// on Success, we want to go to another page;
> '// none of the following alternatives works:
> Response.Redirect("SomeOtherPage.aspx", False)
> Response.Redirect("SomeOtherPage.aspx", True)
> Server.Transfer("SomeOtherPage.aspx", False)
> Server.Transfer("SomeOtherPage.aspx", True)
> Catch ex as Exception
> '// always thread was being aborted error
> End Try
>End Sub
>How do I fix this? Is it a timing issue not under programmer's control?
>Thanks
>K.
>

0 comments:

Post a Comment