예제 #1
0
        /// <summary>
        /// This is a demo of using ChannelEventSource.
        /// </summary>
        public static void Run()
        {
            Out.WriteLine("******************** LocalizedEventLogEventSourceDemo Demo ********************");
            Out.WriteLine("This demonstrate that the events sent to the EventLog will be localized to");
            Out.WriteLine("The culture of the machine.   Currently however the demo only supports English");
            Out.WriteLine("and French.   Thus to see something interesting you must set your machine's");
            Out.WriteLine("culture to French.");

            // We need to simulate deployment of the app, in this case we go to C:\ProgramData\EventSourceSamples
            DeploymentFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), @"EventSourceSamples");
            RegisterEventSourceWithOperatingSystem.SimulateInstall(DeploymentFolder, LocalizedEventLogEventSource.Log.Name);

            RunWorker();        // Generate some events.

            Out.WriteLine("Launching 'start eventvwr' to view the newly generated events.");
            Out.WriteLine("Look in 'Application and Services Logs/Samples/EventSourceDemos/EventLog'");
            Out.WriteLine("To see the localized messages, you need to set your culture to Fr-fr.");
            Out.WriteLine("Close the event viewer when complete.");
            Process.Start(new ProcessStartInfo("eventvwr")
            {
                UseShellExecute = true
            }).WaitForExit();
            Out.WriteLine("Press <Enter> to continue.");
            Console.ReadLine();

            RegisterEventSourceWithOperatingSystem.SimulateUninstall(DeploymentFolder);
            Out.WriteLine();
        }
예제 #2
0
        /// <summary>
        /// This is a demo of using ChannelEventSource.
        /// </summary>
        public static void Run()
        {
            Out.WriteLine("******************** EventLogEventSource Demo ********************");

            // Deploy the app
            DeploymentFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), @"EventSourceSamples");
            RegisterEventSourceWithOperatingSystem.SimulateInstall(DeploymentFolder, EventLogEventSource.Log.Name);

            GenerateEvents();            // Generate some events.

            // Let the user inspect that results
            Out.WriteLine("Launching 'start eventvwr' to view the newly generated events.");
            Out.WriteLine("Look in 'Application and Services Logs/Samples/EventSourceDemos/EventLog'");
            Out.WriteLine("Close the event viewer when complete.");
            Process.Start(new ProcessStartInfo("eventvwr")
            {
                UseShellExecute = true
            }).WaitForExit();
            Out.WriteLine("Press <Enter> to continue.");
            Console.ReadLine();

            // Uninstall.
            RegisterEventSourceWithOperatingSystem.SimulateUninstall(DeploymentFolder);
            Out.WriteLine();
        }