You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Thank you for creating this Powershell Windows Service template.
I ran into an issue with the template in the part where Service part of the code fails with some exception and the logic falls into the "finally" block of the code. As part of the cleanup, "Get-PSThread | Remove-PSThread" is being performed. The Remove-PSThread will call Receive-PSThread to release the resources. The problem is that EndInvoke() method being used in the function will wait for the job to be finished and in this case, we are waiting for a message from the SCM (Receive-PipeMessage) and it may never come. I have tried to replace the EndInvoke() call with the Stop() call which is supposed to kill the job but I am still getting stuck over the call. In short, I am trying to
Start-PipeHandlerThread -pipeName "ControlTest" # Start the thread
Get-PSThread | Remove-PSThread # Shutting it down before any message has been received
The solution I have used to get around in getting stuck in the "finally" block is to inject a message to the named pipe before the cleanup by using Send-PipeMessage.
The text was updated successfully, but these errors were encountered:
thanks for the feedback.
If you're confident that your fix resolves the issue you mentioned, please do a pull request for the original script with just that change.
I'll review it and, if it also looks good to me, I'll merge it in.
Hi,
Thank you for creating this Powershell Windows Service template.
I ran into an issue with the template in the part where Service part of the code fails with some exception and the logic falls into the "finally" block of the code. As part of the cleanup, "Get-PSThread | Remove-PSThread" is being performed. The Remove-PSThread will call Receive-PSThread to release the resources. The problem is that EndInvoke() method being used in the function will wait for the job to be finished and in this case, we are waiting for a message from the SCM (Receive-PipeMessage) and it may never come. I have tried to replace the EndInvoke() call with the Stop() call which is supposed to kill the job but I am still getting stuck over the call. In short, I am trying to
Start-PipeHandlerThread -pipeName "ControlTest" # Start the thread
Get-PSThread | Remove-PSThread # Shutting it down before any message has been received
The solution I have used to get around in getting stuck in the "finally" block is to inject a message to the named pipe before the cleanup by using Send-PipeMessage.
The text was updated successfully, but these errors were encountered: