1

I've been trying to pass parameters to a BackgroundService as a Windows Service. Ideally I would like to use a ServiceController to do this when starting the service. This seems impossible as the Service only accepts Arguments during the Main(string[] args) which is called when the service begins when the computer turns on rather than when the ExecuteAsync is called when the service is Started.

The setup I am using is from this tutorial https://youtu.be/PzrTiz_NRKA?t=1904

The current solution I have implemented uses a configuration file which the Service reads when its starts, this allows for some dynamic configuration but is not ideal. Any Advice is appreciated!

Matt
  • 97
  • 9
  • 1
    Well you could use interprocess communication - https://stackoverflow.com/questions/528652/what-is-the-simplest-method-of-inter-process-communication-between-2-c-sharp-pro – Rand Random Nov 10 '20 at 09:50
  • Noticed that the answers of my shared question, didn't mention gRPC - so here another one whre gRPC is mentioned https://stackoverflow.com/questions/58549763/how-should-ipc-be-handled-in-net-core - – Rand Random Nov 10 '20 at 09:53
  • Thanks for the speedy response, I'll look into this now. Just as an FYI I am using Signalr in the Service already, I noticed it was mentioned in the most recent link. – Matt Nov 10 '20 at 09:57
  • if thats the case maybe you are looking for this - https://stackoverflow.com/questions/17350582/how-to-pass-complex-objects-via-signalr – Rand Random Nov 10 '20 at 10:18

0 Answers0