Hi @Coreysan , Welcome to Microsoft Q&A,
Updated:
The solution for it was to increase the SqlCommand timeout to about 3 minutes.
By default, Windows Service Manager will try to restart a service if it detects a crash. You can check the service's recovery options to make sure it's not restarting when the service fails.
In the "Recovery" tab, look at the settings for "First Failure", "Second Failure", and "Subsequent Failures". You can set them to "No Action" to prevent the service from automatically restarting.
If you start a new thread to handle a task, make sure that thread is not interrupted by a change in the service's state. You can consider using an asynchronous task or BackgroundWorker to handle these long-running operations.
Task.Run(() =>
{
try
{
// Execute your task
}
catch (Exception ex)
{
// Log an error
LogError(ex);
}
});
Best Regards,
Jiale
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.