Answer the question
In order to leave comments, you need to log in
How to subscribe to an event and not close the application?
Good afternoon. I want to make a small console application that would wait for some action in the system, the appearance of a file / device connection / loss of the Internet, etc. it doesn't matter at the moment. I can subscribe MyClass.MyFunction += System.SomeEvent But after that the control flow goes on and the application closes. The question is how to keep the application running and not consume a lot of resources?
PS While (true) {...} and Thread.Sleep take about 20% of CPU work
Answer the question
In order to leave comments, you need to log in
Read keys.
while (true) {
Console.ReadKey(true);
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question