static int Main( string [] args ) { _runLocal = true; try { BooleanSwitch traceEnableSwitch = new BooleanSwitch("TraceEnable", "Enable trace messages"); if (traceEnableSwitch.Enabled) { // Spit all trace output to stdout if desired Console.WriteLine( "Tracing Enabled" ); Trace.Listeners.Add( new TextWriterTraceListener(Console.Out) ); } else { // By default, listen only to the "Error" trace messages // Does not work: what am I doing wrong? Console.WriteLine( "Error Tracing enabled" ); Trace.Listeners.Add( new TextWriterTraceListener(Console.Out, "Error") ); } Trace.AutoFlush = true; // Parse args: for (int i = 0; i < args.Length; i++) { if ("/client" == args[i]) { _runLocal = false; } else { _PrintUsage(); return 1; } } _SetUpRemoting(); _Trace( "Initializing" ); Application.Init (); // New: _Trace( "Creating GtkPlayer" ); gtkPlayer = new GtkPlayer(); _Trace( "Application.Run time" ); Application.Run (); } catch ( Exception e ) { _Trace( "Something is horribly wrong" ); // Deal with unexpected exception by printing a message. Note // that it is possible to generate an excption while printing // the exception, so wrap that sucker too! string errorMsg = null; errorMsg = e.ToString(); Console.WriteLine( "Unexpected Exception: {0}", errorMsg); Console.WriteLine( "Exiting" ); return 1; // ** quick exit ** } _Trace( "exiting" ); // If any stray threads are around, deal with it here. if (_runLocal) _backendInterface.ShutDown(); _scanner = null; _backendProxy = null; _backendInterface = null; return 0; // success }
/// /// If we are running locally, poll this periodically to scan /// for new files in the mp3 dir(s), and do other background /// processing in the Engine. About once per second should do it. /// public static void ScanForFiles() { // Don't bother if no mp3 dirs are configured if (null != _mp3RootDir) { if (null == _scanner) { string nextDir = _mp3RootDir; _Trace( "Now scanning: " + nextDir ); _scanner = _CreateRecursiveScanner( nextDir ); } Debug.Assert( _scanner != null, "logic error" ); if (_scanner.DoNextFile(5, backendInterface) == ScanStatus.FINISHED) { _Trace( "Scan Finished" ); _scanner = null; } } }