public StatisticsHandler(Mode.Config config, Action <ulong, ulong, List <ServerStatItem> > update) { //try //{ // if (Environment.Is64BitOperatingSystem) // { // FileManager.UncompressFile(Utils.GetPath("grpc_csharp_ext.x64.dll"), Resources.grpc_csharp_ext_x64_dll); // } // else // { // FileManager.UncompressFile(Utils.GetPath("grpc_csharp_ext.x86.dll"), Resources.grpc_csharp_ext_x86_dll); // } //} //catch (IOException ex) //{ // Utils.SaveLog(ex.Message, ex); //} config_ = config; Enable = config.enableStatistics; UpdateUI = false; updateFunc_ = update; exitFlag_ = false; LoadFromFile(); GrpcInit(); Task.Run(() => Run()); }
public StatisticsHandler(Mode.Config config, Action <ulong, ulong, List <ServerStatItem> > update) { try { if (Environment.Is64BitOperatingSystem) { FileManager.UncompressFile(Utils.GetPath("grpc_csharp_ext.x64.dll"), Resources.grpc_csharp_ext_x64_dll); } else { FileManager.UncompressFile(Utils.GetPath("grpc_csharp_ext.x86.dll"), Resources.grpc_csharp_ext_x86_dll); } } catch (IOException ex) { Utils.SaveLog(ex.Message, ex); } config_ = config; Enable = config.enableStatistics; UpdateUI = false; updateFunc_ = update; exitFlag_ = false; LoadFromFile(); GrpcInit(); workThread_ = new Thread(new ThreadStart(Run)); workThread_.IsBackground = true; workThread_.Start(); }
public MainForm(Mode.Config predefined = null) { InitializeComponent(); this.ShowInTaskbar = false; this.WindowState = FormWindowState.Minimized; this.Text = Utils.GetVersion(); Application.ApplicationExit += (sender, args) => { Utils.ClearTempPath(); }; config = predefined; }
private bool exitFlag_; // true to close workThread_ public StatisticsHandler(Mode.Config config, Action <ulong, ulong, ulong, ulong, List <Mode.ServerStatistics> > update) { try { if (Environment.Is64BitOperatingSystem) { FileManager.UncompressFile(Utils.GetPath("grpc_csharp_ext.x64.dll"), Resources.grpc_csharp_ext_x64_dll); } else { FileManager.UncompressFile(Utils.GetPath("grpc_csharp_ext.x86.dll"), Resources.grpc_csharp_ext_x86_dll); } } catch (IOException ex) { Utils.SaveLog(ex.Message, ex); } config_ = config; enabled_ = config.enableStatistics; UpdateUI = false; updateFunc_ = update; logPath_ = Utils.GetPath(Global.StatisticLogDirectory); Statistic = new List <Mode.ServerStatistics>(); exitFlag_ = false; DeleteExpiredLog(); foreach (var server in config.vmess) { var statistic = new ServerStatistics(server.remarks, server.address, server.port, server.path, server.requestHost, 0, 0, 0, 0); Statistic.Add(statistic); } LoadFromFile(); GrpcInit(); workThread_ = new Thread(new ThreadStart(Run)); workThread_.IsBackground = true; workThread_.Start(); }
private bool exitFlag_; // true to close workThread_ public StatisticsHandler(Mode.Config config, Action <ulong, ulong, ulong, ulong, List <Mode.ServerStatistics> > update) { config_ = config; enabled_ = config.enableStatistics; UpdateUI = false; updateFunc_ = update; logPath_ = Utils.GetPath(Global.StatisticLogDirectory); Statistic = new List <Mode.ServerStatistics>(); exitFlag_ = false; DeleteExpiredLog(); foreach (var server in config.vmess) { var statistic = new ServerStatistics(server.remarks, server.address, server.port, server.path, server.requestHost, 0, 0, 0, 0); Statistic.Add(statistic); } LoadFromFile(); GrpcInit(); workThread_ = new Thread(new ThreadStart(Run)); workThread_.Start(); }
public void Switch(Mode.Config config) { OnSwitch?.Invoke(config); }