now there is a console program written by. Net core. The publish target is ubuntu-16.04-x64, and then you want to resident in the background as a daemon under Ubuntu, and start the timer to perform a series of operations. The code is as follows:
1. Call a method in .dll in console program.cs to open TCP
ChildTCPServerHelper.Instance.OnInitSuccess += _ChildTCPServerHelper_OnInitSuccess;
ChildTCPServerHelper.Instance.CreateTCPServer();
2. Then CreateTCPServer () in the ChildTCPServerHelper class starts the timer:
_ HandleCanUsePortTimer = new Timer ();
_HandleCanUsePortTimer.Interval = 2000; //21
_HandleCanUsePortTimer.Elapsed += _HandleCanUsePortTimer_Elapsed;
_HandleCanUsePortTimer.Elapsed.Start();
but the problem is that after executing the start, the program does not execute the timer event, but instead comes to the point where it exits the program (because the CreateTCPServer () function is the last step of the console program). I would like to ask the gods how to make this console program permanent in the background.