C# console program wait forever for event -


i have simple c# console application attaches event. need program keep running continuously can respond event. right way keep running?

here application:

using system; using naudio.coreaudioapi;  namespace maxvolume {     class program     {         private const float desiredlevel = -15;         private static mmdevice _device;          static void main(string[] args)         {             mmdeviceenumerator mmde = new mmdeviceenumerator();             _device = mmde.getdefaultaudioendpoint(dataflow.render, role.multimedia);              _device.audioendpointvolume.mastervolumelevel = desiredlevel;              _device.audioendpointvolume.onvolumenotification += setvolume;         }          static void setvolume(audiovolumenotificationdata data)         {             if (math.abs(data.mastervolume - desiredlevel) > 0.1)             {                 _device.audioendpointvolume.mastervolumelevel = desiredlevel;             }         }     } } 

you can call console.readline() (if want terminate on keystroke), or thread.sleep(timeout.infinite).


Comments