public Service1() { InitializeComponent(); detector = new DTMFDetector(); wcfInstance = new DTMFServiceCtrl(); wcfInstance.onStopDetect += wcfInstance_onStopDetect; wcfInstance.onStartDetect += wcfInstance_onStartDetect; host = new ServiceHost(wcfInstance); detector.ToneDetected += detector_ToneDetected; detector.EndRecording += detector_EndRecording; detector.DetectSilence = false; detecting = false; try { interval = Convert.ToInt16(ConfigurationManager.AppSettings["service_address"]); var config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); System.Configuration.AppSettingsSection section = config.AppSettings; detecting = Convert.ToBoolean(section.Settings["detecting"].Value); } catch (Exception e) { interval = 1; } if (detecting) { detector.StartDetect(); wcfInstance.StartDetect(); } timer = new Timer(SelfNotification, null, 0, interval * 60000); }
void wcfInstance_onStartDetect(object sender, EventArgs e) { detecting = true; detector.StartDetect(); var config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); System.Configuration.AppSettingsSection section = config.AppSettings; section.Settings.Remove("detecting"); section.Settings.Add("detecting", "true"); config.Save(ConfigurationSaveMode.Modified); }
static void Main(string[] args) { var d = new DTMFDetector(); d.ToneDetected += d_ToneDetected; d.StartDetect(); Console.WriteLine("Press <Enter> to exit"); ConsoleKeyInfo c; while ((c = Console.ReadKey()).Key != ConsoleKey.Enter) { Console.WriteLine("Press <Enter> to exit"); } }
static void wcfInstance_onStartDetect(object sender, EventArgs e) { detecting = true; detector.StartDetect(); }