Changing hosting mechanism for scheduler

66 views Asked by At

I have one scheduler which is running on Windows Service. For each new event it creates new thread. Each thread then load DLL using AddIn Framework and execute the task.

It is working fine but now but according to new requirement i want to be able to kill any event if we decide to do so or event is taking much time in execution.

Code for starting thread

 ThreadStart ts = KickOffEvents;
 Thread t = new Thread(ts);

So to do that i need to issue something so scheduler can understand and kill specific thread. But as that scheduler hosted on window service i am not able to do so.

Can anyone tell any work around in this???

Currently i am working on to move scheduling functionality to IIS by creating WCF service. Then i will be able to call function of wcf service which will in a way kill any event(thread).

Can anyone provide any input in whether any underlying risk in doing so???

Thanks in Advance

1

There are 1 answers

2
Richard Blewett On

There is no way for the scheduler to explicitly kill the thread it has spawned. You will need to set a flag that the thread looks for and it will have to bring itself down. Anything else can result in undefined behavior

You can use a WCF service request to set this flag