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

Thread.Abort in Web Service

I am using a third party DLL which is the interface to an off-the-shelf
document management system (so I have to use it). Unfortunately it is very
poor and if there is a problem with the server, calls to this DLL simply hang
(on the order of 5 minutes). When this occurs that means there is a problem
with the Server and I need to communicate back to the consumers of my Web
Service this is the case. Basically, I need to set some kind of timeout and
interrupt the dll call. My first solution was as follows...(or some
variation thereof)

public class MyService : WebService
{
private Thread _primaryThread;
private System.Timers.Timer _timeoutTimer;

public MyService()
{
InitializeComponent();
_primaryThread = Thread.CurrentThread;
_timeoutTimer = new System.Timers.Timer( 60 * 1000 );
_timeoutTimer.AutoReset = false;
_timeoutTimer.Elapsed += new ElapsedEventHandler(
TimeoutTimer_Elapsed );
_timeoutTimer.Start();
}

private void TimeoutTimer_Elapsed( object sender, ElapsedEventArgs e )
{
_primaryThread.Abort();
}

[WebMethod]
public void MyWebMethod()
{
try
{
// Make dll call and do other stuff
}
catch( ThreadAbortException e )
{
// Handle the timeout
}
catch( Exception e )
{
// Handle other exceptions
}
}
}

So, when the user calls MyWebMethod() the timer is started and when it
elapses it aborts the thread in which MyWebMethod is running.
However, MyWebMethod() does not catch the ThreadAbortException. Rather,
..NET catches it and returns some html text (not SOAP) containing details of
the Thread.Abort(). So, I can't catch the ThreadAbortException()? - why?

Any ideas?

Thanks,
--
Dan S

--
Dan S
Nov 23 '05 #1
0 5948

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

Similar topics

2
by: cottonviking | last post by:
Greetings, all! I've been pondering the pitfalls of aborting a secondary thread in a service app I'm writing (VB, fx v1.1). Everything I've read so far pretty much dissuades one from aborting one...
7
by: Morris | last post by:
I want to abort a running thread, so I call MyThread.abort() function. My problem is this thread runs "almost" like a while(true) loop and I don't want the Abort() function interrupts the thread at...
20
by: Doug Thews | last post by:
I ran into an interesting re-pain delay after calling the Abort() method on a thread, but it only happens the very first time I call it. Every time afterward, there is no delay. I've got a...
13
by: Andy Fish | last post by:
Hi, I am using COM interop to invoke MS word from my .net app. If word pops up a dialog box, my thread obviously hangs until the dialog is answered. Here's the problem: because the app is...
1
by: benmorganpowell | last post by:
I have a small windows service which connects to a POP3 server at defined intervals, scans the available messages, extracts the required information and inserts the data into a SQL database. I am...
3
by: Terry Olsen | last post by:
I'm trying to shutdown my service by stopping all the started classes & threads. In each Class I have a Public Sub like this: Public Sub StopIntf() Try Threading.Thread.CurrentThread.Abort()...
7
by: IsRaEl | last post by:
Hello I have a thread that start a really boring process of upload and download a bunch of 1kb files on a server. Since my internet connection SUCKS, during the download process, the class that...
4
by: Mufasa | last post by:
Is there any way to force a thread to abort and really have it abort? I have a thread that every once in a while gets hung to so I kill it. Problem is I have a thread that every once in a while...
18
by: =?Utf-8?B?VGhlU2lsdmVySGFtbWVy?= | last post by:
Because C# has no native SSH class, I am using SharpSSH. Sometimes, for reasons I do not know, a Connect call will totally lock up the thread and never return. I am sure it has something to do...
4
by: raghudr | last post by:
Hi all, I am implemeting a splash screen in C# I got a useful link from here :- http://www.codersource.net/csharp_splash_screen.aspx //Logic when to display a splash screen is:- Splash...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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:
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
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
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,...

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.