Search code examples
fiddlerfiddlercore

How Can i Stop FiddlerCore When Windows is Shutting Down


i have a C# console application when the software is installed am starting the proxy but not stopping it when it shutdowns....so when the next time start the pc, the app should not start... or will start but will malfunction in order to avoid that i think its needs to be Shutdown properly Using using a windows service.... because at time of shutdown windows os guarranty to stop them first then shutdown

So please help me How can i stop the Fiddler When the windows shutting down.

Thanks in advance.


Solution

  • You can subscribe to system shutdown event and then shutdown fiddler.

    SystemEvents.SessionEnded += SessionEnderEventHandler;
    static void SessionEnderEventHandler(object sender, SessionEndedEventArgs e)
            {
                Console.WriteLine("Shutting down...");
                Fiddler.FiddlerApplication.Shutdown();
                System.Threading.Thread.Sleep(750);
            }