G
Guest
Good Day,
I have a Windows Service that is responsible for processing somes files. One
method of the service invokes another method which may take a while to
complete its work. Something like this
pulbic class A
{
public void ProcessFile()
{
B Test = new B();
Test.DoWork();
}
}
public class B
{
public void DoWork()
{
//Long Running Method
}
}
Here is my problem. I need a way to signal the DoWork method that the
service has been called to stop and it need to finish whatever it is doing
gracefully and exit. So far the only solution I can come up with is to launch
the method on its own seperate thread. Then, the other method can monitor the
thread until it is done. If it needs to stop it can set a flag on the object
telling it to stop processing.
Is this really the best way to do this? Is there another way to achieve this
without launching a seperate thread?
Just looking for ideas. Thanks!
Dan
I have a Windows Service that is responsible for processing somes files. One
method of the service invokes another method which may take a while to
complete its work. Something like this
pulbic class A
{
public void ProcessFile()
{
B Test = new B();
Test.DoWork();
}
}
public class B
{
public void DoWork()
{
//Long Running Method
}
}
Here is my problem. I need a way to signal the DoWork method that the
service has been called to stop and it need to finish whatever it is doing
gracefully and exit. So far the only solution I can come up with is to launch
the method on its own seperate thread. Then, the other method can monitor the
thread until it is done. If it needs to stop it can set a flag on the object
telling it to stop processing.
Is this really the best way to do this? Is there another way to achieve this
without launching a seperate thread?
Just looking for ideas. Thanks!
Dan