Hi,
I've implemented a windows service that calls an SSIS package. Every
so often, the SSIS package does not return control to the calling
method. What I've implemented is a sentinel thread that is spawned
before the execute method of the SSIS package which will email me if
execution occurs for a prolonged period. What I want to know is, how
can I implement a solution that will force the SSIS object to timeout
and return control to the calling method in the event handler of the
sentinel thread? Code samples would be appreciated.
Thanks,
Roger
zacks@construction-imaging.com - 28 Mar 2008 20:53 GMT
> Hi,
>
[quoted text clipped - 10 lines]
>
> Roger
To exit out of a method before it has completed, just do a:
return;
Roger - 28 Mar 2008 21:25 GMT
On Mar 28, 3:53 pm, za...@construction-imaging.com wrote:
> > Hi,
>
[quoted text clipped - 14 lines]
>
> return;
The problem is, the SSIS object retains control due to a deadlocking
issue and doesn't give me the opportunity to return. I need another
method of raising exception from method without stopping the service
outright.
Roger - 28 Mar 2008 22:04 GMT
> On Mar 28, 3:53 pm, za...@construction-imaging.com wrote:
>
[quoted text clipped - 21 lines]
> method of raising exception from method without stopping the service
> outright.
Nevermind. I figured out that I can run through all the running SSIS
packages and shutdown the offending packages.
rossum - 28 Mar 2008 22:07 GMT
>Hi,
>
[quoted text clipped - 10 lines]
>
>Roger
Call SSIS in a worker thread. Spawn your sentinel thread. If the
Sentinel thread finishes before the SSIS thread then kill the SSIS
thread from you main thread.
If you are not actually doing anything in your main thread then you
might be able to replace the sentinel thread with a simple timer in
the main thread.
rossum
Lasse Vågsæther Karlsen - 29 Mar 2008 12:59 GMT
>> Hi,
>>
[quoted text clipped - 19 lines]
>
> rossum
Do not kill another thread forcibly. You need to figure out a way to
talk to the other thread and have it exit by its own.
Killing a thread is doable if your program is to be closed down, but
other than that, it's a big no-no.

Signature
Lasse Vågsæther Karlsen
mailto:lasse@vkarlsen.no
http://presentationmode.blogspot.com/
PGP KeyID: 0xBCDEA2E3
rossum - 29 Mar 2008 13:31 GMT
>Do not kill another thread forcibly. You need to figure out a way to
>talk to the other thread and have it exit by its own.
Agreed. Normally I would send a "Please die now" message to the
thread I wanted to kill.
rossum
Howard Swope - 29 Mar 2008 23:29 GMT
I often do something like this:
using System;
using System.Threading;
namespace CSConsole
{
class Program
{
static void Main()
{
Console.WriteLine("Monitor thread starting worker thread.");
Thread thread = new Thread(ThreadProc);
thread.Start();
Console.WriteLine("Monitor thread watching worker for time out.");
if (!thread.Join(5000))
{
Console.WriteLine("Monitor thread determines worker has timed out and calls abort.");
thread.Abort(); // thread timed out
}
Console.WriteLine("Monitor thread waits until worker thread is cleaned up.");
// wait until thread is done
thread.Join(-1);
Console.WriteLine("Monitor thread done. Press a key to quit.");
Console.ReadLine();
}
static void ThreadProc()
{
try
{
Console.WriteLine("Worker thread is doing work.");
// my bad thread is locked up
while (true)
{
Thread.Sleep(0);
}
}
catch (ThreadAbortException)
{
Console.WriteLine("Worker thread received abort signal.");
}
finally
{
Console.WriteLine("Worker thread cleaning up.");
}
}
}
}
> Hi,
>
[quoted text clipped - 10 lines]
>
> Roger