C# - Close OpenVPN Cleanly

前端 未结 2 1407
慢半拍i
慢半拍i 2021-01-07 14:21

We have written an application that sits in the tray controlling OpenVPN as an extension to a bigger application.

If you run openvpn.exe on command line, you can pre

2条回答
  •  鱼传尺愫
    2021-01-07 15:08

    If I run OpenVPN as the following:

    "openvpn.exe --config PathToMyConfig.ovpn --service MyEventName 0"
    

    Then the following C# code causes OpenVPN to exit cleanly:

    EventWaitHandle resetEvent = EventWaitHandle.OpenExisting("MyEventName");
    
    resetEvent.Set();
    

    Props to consultutah, his comments helped quite a bit.

提交回复
热议问题