Beispiel #1
0
        static void Main(string[] args)
        {
            #region ====================用API安装事件处理
            ConsoleCtrlDelegate newDelegate = new ConsoleCtrlDelegate(HandlerRoutine);
            bool bRet = SetConsoleCtrlHandler(newDelegate, true);
            if (bRet == false)  //安装事件处理失败
            {
                Log.WriteLog("添加响应关闭事件失败", "");
            }
            else
            {
                Log.WriteLog("添加响应关闭事件成功", "");
            }
            #endregion

            Console.WriteLine("提示:");
            Console.WriteLine("1、按回车键结束程序;");
            Console.WriteLine("2、获取K线和分时数据及初始化行情数据;");
            Console.WriteLine("3、程序执行中...");

            new BLL.tasks_opt_lot().Action();

            var input = Console.ReadLine();
            while (input != "quit")
            {
                if (input == "cls")
                {
                    Console.Clear();
                }
                input = Console.ReadLine();
            }
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            AppDomain.CurrentDomain.UnhandledException += CurrentDomainUnhandledException;

            CameraInfo camera1 = new CameraInfo("TEST1", "172.31.108.248", 8000, "admin", "1234Qwer");

            try
            {
                var task = Task.Factory.StartNew(() =>
                {
                    //1、启动
                    faceDetectAlarm.Initial(null, 0.6);

                    //2、登录摄像机
                    int irc = faceDetectAlarm.LoginCamera(camera1);
                    if (irc <= 0)
                    {
                        Debug.Print("LOGIN ERROR");
                        return;
                    }

                    //3、启动布防
                    faceDetectAlarm.StartAlarm();

                    faceDetectAlarm.NoticeFaceSnapEvent += delegate(string strSnapTime, string strDevIP, string strFilePath, Rectangle rectFace)
                    {
                        Debug.Print(strSnapTime + "," + strDevIP + "," + strFilePath);
                        Console.WriteLine(strSnapTime + "," + strDevIP + "," + strFilePath + "," + rectFace.ToString());
                    };

                    //4、启动监听
                    faceDetectAlarm.StartListen(PortHelper.GetFirstAvailablePort());
                });

                Thread.Sleep(1000);

                ConsoleCtrlDelegate newDategate = HandlerRoutine;
                var re = SetConsoleCtrlHandler(newDategate, true);
                if (!re)
                {
                    Console.WriteLine("Set SetConsoleCtrlHandler Error! ");
                }

                // Request cancellation from the UI thread.
                if (Console.ReadKey().KeyChar == 'c')
                {
                    HandlerRoutine(CTRL_CLOSE_EVENT);
                }

                // Keep the console window open while the
                // task completes its output.
                Console.ReadLine();
            }
            catch (Exception ex)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("Application Exception:" + ex.Message);
                Console.ForegroundColor = ConsoleColor.Black;
            }
        }
Beispiel #3
0
        private async Task <bool> SendCtrlSignal(ConsoleCtrlEvent signal, TimeSpan timeout)
        {
            Trace.Info($"Sending {signal} to process {_proc.Id}.");
            ConsoleCtrlDelegate ctrlEventHandler = new ConsoleCtrlDelegate(ConsoleCtrlHandler);

            try
            {
                if (!FreeConsole())
                {
                    throw new Win32Exception(Marshal.GetLastWin32Error());
                }

                if (!AttachConsole(_proc.Id))
                {
                    throw new Win32Exception(Marshal.GetLastWin32Error());
                }

                if (!SetConsoleCtrlHandler(ctrlEventHandler, true))
                {
                    throw new Win32Exception(Marshal.GetLastWin32Error());
                }

                if (!GenerateConsoleCtrlEvent(signal, 0))
                {
                    throw new Win32Exception(Marshal.GetLastWin32Error());
                }

                Trace.Info($"Successfully send {signal} to process {_proc.Id}.");
                Trace.Info($"Waiting for process exit or {timeout.TotalSeconds} seconds after {signal} signal fired.");
                var completedTask = await Task.WhenAny(Task.Delay(timeout), _processExitedCompletionSource.Task);

                if (completedTask == _processExitedCompletionSource.Task)
                {
                    Trace.Info("Process exit successfully.");
                    return(true);
                }
                else
                {
                    Trace.Info($"Process did not honor {signal} signal within {timeout.TotalSeconds} seconds.");
                    return(false);
                }
            }
            catch (Exception ex)
            {
                Trace.Info($"{signal} signal doesn't fire successfully.");
                Trace.Verbose($"Catch exception during send {signal} event to process {_proc.Id}");
                Trace.Verbose(ex.ToString());
                return(false);
            }
            finally
            {
                FreeConsole();
                SetConsoleCtrlHandler(ctrlEventHandler, false);
            }
        }
Beispiel #4
0
        public static bool SetConsoleCtrlHandler(ConsoleCtrlDelegate handlerRoutine, bool add)
        {
            switch (PlatformIdentifier)
            {
            case PlatformID.Win32NT:
                return(Win32SetConsoleCtrlHandler(handlerRoutine, add));

            default:
                return(true);
            }
        }
Beispiel #5
0
        static void Main(string[] args)
        {
            ConsoleCtrlDelegate consoleDelegete = new ConsoleCtrlDelegate(ProcessEvent);

            SetConsoleCtrlHandler(consoleDelegete, true);//处理ctrl按键
            if (args.Length < 2)
            {
                printUsage();
                return;
            }
            new Program().Process(args);
        }
Beispiel #6
0
 public ConsoleExitHanlder()
 {
     try
     {
         this.consoleCtrlDelegate = new ConsoleCtrlDelegate(HandlerRoutine);
         NativeMethods.SetConsoleCtrlHandler(this.consoleCtrlDelegate, true);
     }
     catch (Exception ex)
     {
         Console.WriteLine("Set SetConsoleCtrlHandler Error : {0}", ex.Message);
     }
 }
        /// <summary>
        ///     Start SpBlockChain service
        /// </summary>
        public void Start()
        {
            _log.Info("================================================================================");
            _log.Info("StartUp: " + DateTime.Now.ToString());
            _log.InfoFormat("SmartPesa BlockChain Subscriber v{0}", this.GetType().Assembly.GetName().Version.ToString());
            _log.Info("SmartPesa MQ Version: " + ZeroMQ.lib.zmq.LibraryVersion);
            _log.Info("");
            _serverTask = new Task(ZmqTransactionWorker);
            _serverTask.Start();

            // setup console event handler
            _closeHandler += new ConsoleCtrlDelegate(ConsoleCtrlCheck);
            SetConsoleCtrlHandler(_closeHandler, true);
        }
Beispiel #8
0
        static void Main(string[] args)
        {
            // 读取文件
            {
                StreamReader sr     = new StreamReader("data/config.json", System.Text.Encoding.GetEncoding("utf-8"));
                string       config = sr.ReadToEnd().ToString();
                sr.Close();

                ConfigEntity.getInstance().data = JsonConvert.DeserializeObject <ConfigData>(config);
            }

            if (true)
            {
                var configData = ConfigEntity.getInstance().data;
                Socket_S.getInstance().Start("0.0.0.0", configData.server_port);
                Socket_S.getInstance().m_onSocketEvent_Receive = OnReceive;

                {
                    // 用API安装事件处理
                    ConsoleCtrlDelegate newDelegate = new ConsoleCtrlDelegate(HandlerRoutine);
                    bool bRet = SetConsoleCtrlHandler(newDelegate, true);
                    if (bRet == false)
                    {
                        // 安装关闭事件失败
                    }
                    else
                    {
                        // 安装关闭事件成功
                    }
                }

                // 打开数据库
                // MySqlUtil.getInstance().openDatabase();
            }

            Console.ReadKey();
            Console.ReadKey();
            Console.ReadKey();
            Console.ReadKey();
            Console.ReadKey();
            Console.ReadKey();
            Console.ReadKey();
        }
Beispiel #9
0
        static void Main(string[] args)
        {
            Int32 ret = 0;

            if ((ret = fnMPU6050SerialReceiverDynamicLibraryProcess(21, 2000000, new ProcCallBack(ProcessCallBackFuncInstance))) != 0)
            {
                Console.WriteLine("Start Process Error, Error Code:{0}", ret);
                return;
            }

            ConsoleCtrlDelegate newDelegate = new ConsoleCtrlDelegate(HandlerRoutine);

            if (SetConsoleCtrlHandler(newDelegate, true))
            {
                while (true)
                {
                    ;
                }
            }
            return;
        }
Beispiel #10
0
        static void Main(string[] args)
        {
            #region ====================用API安装事件处理
            ConsoleCtrlDelegate newDelegate = new ConsoleCtrlDelegate(HandlerRoutine);
            bool bRet = SetConsoleCtrlHandler(newDelegate, true);
            if (bRet == false)  //安装事件处理失败
            {
                Log.WriteLog("添加响应关闭事件失败", "");
            }
            else
            {
                Log.WriteLog("添加响应关闭事件成功", "");
            }
            #endregion

            Console.WriteLine("提示:");
            Console.WriteLine("1、按回车键结束程序;");
            Console.WriteLine("2、获取K线和分时数据及初始化行情数据;");
            Console.WriteLine("3、程序执行中...");
            BLL.tasks_k_t_line_bak gp_bll = new BLL.tasks_k_t_line_bak();
            gp_bll.Action();
            Console.ReadLine();
        }
        public void OnAction(Hashtable parameters)
        {
            Console.Title = "Build by Thiago Hajjar";
            Console.WriteLine("Starting GameServer ... Edit by Thiago Hajjar!");
            GameServer.CreateInstance(new GameServerConfig());
            GameServer.Instance.Start();
            GameServer.KeepRunning = true;
            Console.WriteLine("Server started!");
            client = new ConsoleClient();
            Thread thread = new Thread(() => Application.Run(new CommandForm()));

            thread.SetApartmentState(ApartmentState.STA);
            thread.Start();
            while (GameServer.KeepRunning)
            {
                try
                {
                    handler = new ConsoleCtrlDelegate(ConsoleStart.ConsoleCtrHandler);
                    SetConsoleCtrlHandler(handler, true);
                    Console.Write("> ");
                    string[]      source = Console.ReadLine().Split(new char[] { ' ' });
                    List <string> list   = source.ToList <string>();
                    list.RemoveAt(0);
                    DoCommand(source[0], list.ToArray());
                }
                catch (Exception exception)
                {
                    Console.WriteLine(exception);
                }
            }
            if (GameServer.Instance != null)
            {
                GameServer.Instance.Stop();
            }
            LogManager.Shutdown();
        }
Beispiel #12
0
 static extern bool SetConsoleCtrlHandler(ConsoleCtrlDelegate handlerRoutine, bool add);
Beispiel #13
0
		public static extern bool SetConsoleCtrlHandler(ConsoleCtrlDelegate handlerRoutine, bool add);
Beispiel #14
0
 internal CriticalCtrlHandler()
 {
     consoleCtrlDelegate = new ConsoleCtrlDelegate(ConsoleCtrlCheck);
     ok = SetConsoleCtrlHandler(consoleCtrlDelegate, true);
 }
Beispiel #15
0
 private static extern bool SetConsoleCtrlHandler(ConsoleCtrlDelegate e, bool add);
Beispiel #16
0
 private static extern int SetConsoleCtrlHandler(ConsoleCtrlDelegate ctrlDelegate, int Add);
Beispiel #17
0
 private static extern bool Win32SetConsoleCtrlHandler(ConsoleCtrlDelegate handlerRoutine, bool add);
Beispiel #18
0
        static void Main(string[] args)
        {
            AppDomain.CurrentDomain.UnhandledException += CurrentDomainUnhandledException;

            // 判断是否已经启动过,禁止启动多个
            var runflag = false;
            var mutex   = new Mutex(true, "ImageSplicer", out runflag);

            if (!runflag)
            {
                return;
            }

            Console.Title           = "图像处理接口程序V2.1.0703";
            Console.ForegroundColor = ConsoleColor.Green;
            try
            {
                //1、图像处理线程
                _notifyImager.StartListen();

                //2、数据获取线程
                _imgkafkaActor.Initial();

                Console.WriteLine("已启动正常运行!", EventLogEntryType.Warning);
                Log4NetHelper.Instance.Info("图像处理接口程序-已启动正常运行!");

                var options = new Options();
                if (CommandLine.Parser.Default.ParseArguments(args, options))
                {
                    string file        = options.AppDir;
                    int    newMaxSteps = options.MaxSteps;
                }
                else
                {
                    // Console.WriteLine(options.GetUsage());
                }

                var command = new InvokeCommand();
                while (true)
                {
                    ConsoleCtrlDelegate newDategate = HandlerRoutine;
                    var re = SetConsoleCtrlHandler(newDategate, true);
                    if (!re)
                    {
                        Console.WriteLine("Set SetConsoleCtrlHandler Error! ");
                    }

                    var lCommand = "";
                    Console.Write("JP>");
                    lCommand = Console.ReadLine();

                    if (!string.IsNullOrEmpty(lCommand))
                    {
                        var commandName = lCommand.ToLower();
                        commandName = commandName.Substring(0, 1).ToUpper() + commandName.Substring(1);
                        var method = typeof(InvokeCommand).GetMethod(commandName);
                        if (method == null)
                        {
                            Console.WriteLine("不能识别的命令,键入help查看帮助。\n");
                        }
                        else
                        {
                            try
                            {
                                method.Invoke(command, null);
                            }
                            catch (Exception ex)
                            {
                                Console.WriteLine(ex.Message);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("ERROR:" + (ex.InnerException != null ? ex.InnerException.Message : ex.Message));
                Console.WriteLine("按下回车键以退出...");
                Console.ReadLine();
                Environment.Exit(-1);
            }
        }
Beispiel #19
0
        bool Start()
        {
            bool success = false;

            // Delegate for the control handler to handle console break and close events
            ConsoleCtrlDelegate console_ctrl_delegate = null;

            // Event window to handle console-minimize events
            ConsoleEventWindow console_event_window = null;

            // Event watcher to handle WMI brightness events
            ManagementEventWatcher watcher = null;

            /* If it was requested to hide the console do that first, since doing anything else
             * first would mean the console is more likely to be seen (ie flicker) even if it should
             * be hidden.
             */
            if (we_own_the_console)
            {
                if (opt_hide_on_start || (opt_hide_on_minimize && IsIconic(GetConsoleWindow())))
                {
                    MinimizeAndHideWindow(GetConsoleWindow());
                }
                Console.BufferHeight = 10000;
            }
            else
            {
                if (opt_hide_on_start || opt_hide_on_minimize)
                {
                    Console.WriteLine(
                        "WARNING: " + ProgName + " isn't running in its own console window, so " +
                        "the options that were specified to hide the console are being ignored.\n"
                        );
                }
            }

            string title = ProgName + ": Sync AC & DC brightness";

            Console.Title = title;
            Console.WriteLine(title);
            Console.WriteLine("");
            Console.WriteLine("Use option /? for usage information.");
            Console.WriteLine("");

            // Synchronization used by other threads to run code in this main UI thread
            UISyncContext = new WindowsFormsSynchronizationContext();
            SynchronizationContext.SetSynchronizationContext(UISyncContext);

            // Pop our console to the front when we're signaled by a secondary instance
            ThreadPool.RegisterWaitForSingleObject(RestoreConsoleEvent,
                                                   delegate
            {
                IntPtr console = GetConsoleWindow();
                ShowWindow(console, SW_MINIMIZE);
                ShowWindow(console, SW_RESTORE);
            },
                                                   null, -1, false);

            if (we_own_the_console)
            {
                Tray_Create();

                console_ctrl_delegate = new ConsoleCtrlDelegate(ConsoleCtrlHandlerRoutine);
                SetConsoleCtrlHandler(console_ctrl_delegate, true);

                if (opt_hide_on_minimize)
                {
                    console_event_window = new ConsoleEventWindow(GetConsoleWindow());

                    Console.Title += "   (minimize-to-tray enabled)";

                    /* If the console window is already minimized then emulate the notification to
                     * the event window. It's important to send this so that the event window is
                     * hidden in a way that the window manager unhides it when the console window is
                     * restored.
                     *
                     * It's possible to have a race condition here, for example the console window
                     * is minimized during or after the event window is created but before this
                     * code, so the event window may receive the message twice. That is fine, the
                     * window manager tracks the event window status properly and it will still
                     * unhide the event window properly when the console window is restored.
                     */
                    if (IsIconic(GetConsoleWindow()))
                    {
                        //Console.Beep(300, 250);
                        SendMessage(console_event_window.Handle, WM_SHOWWINDOW, NULL, (IntPtr)SW_PARENTCLOSING);
                    }
                }
            }

            // Global mutex to handle multiple sessions running this program at the same time
            if (SyncBrightnessMutex == null)
            {
                SecurityIdentifier sid  = new SecurityIdentifier(WellKnownSidType.WorldSid, null);
                MutexAccessRule    rule = new MutexAccessRule(sid, MutexRights.FullControl, AccessControlType.Allow);
                MutexSecurity      sec  = new MutexSecurity();
                sec.AddAccessRule(rule);
                bool created_new = false;
                SyncBrightnessMutex = new Mutex(false, SyncBrightnessMutexName, out created_new, sec);
            }

            //todo:Is there a way to get brightness changed event using Win32 API without WMI?
            string scope = @"\\localhost\root\WMI";
            string query = "SELECT * FROM WmiMonitorBrightnessEvent";

            watcher = new ManagementEventWatcher(scope, query);
            watcher.EventArrived += new EventArrivedEventHandler(OnBrightnessChanged);

            Console.WriteLine("Monitoring brightness change...");

            SyncBrightness();

            // Start monitoring brightness events. The watcher calls SyncBrightness when necessary.
            try {
                watcher.Start();
            }
            // Check for access denied, for example a Guest account can't monitor brightness events.
            catch (UnauthorizedAccessException) {
                Console.Error.WriteLine("\nError: Can't monitor brightness events, access denied.");
                goto Cleanup;
            }
#if DEBUG
            // Force GC to help coax out any bugs that otherwise wouldn't be apparent.
            GC.Collect();
            GC.WaitForPendingFinalizers();
            GC.Collect();
#endif
            // Start the message loop to handle synchronization events and window messsages.
            Application.Run();
            // Application.Run() returns due to Application.Exit().
            // Currently that only happens at the user's request.
            success = true;

Cleanup:

            /* Do a graceful cleanup.
             * Note since this is a console application if the user closes the console window then
             * this code is never reached. Refer to ConsoleCtrlHandlerRoutine.
             */
            if (console_ctrl_delegate != null)
            {
                SetConsoleCtrlHandler(console_ctrl_delegate, false);
            }

            if (Tray != null)
            {
                Tray.Dispose();
            }

            if (watcher != null)
            {
                watcher.Stop();
            }

            GC.KeepAlive(console_event_window);
            return(success ? true : false);
        }
Beispiel #20
0
        /// <summary>
        /// Handles the server action
        /// </summary>
        /// <param name="parameters"></param>
        public void OnAction(Hashtable parameters)
        {
            Console.WriteLine("This server DDTankII, edit and build by Trminhpc!");
            Console.WriteLine("Starting GameServer ... please wait a moment!");
            GameServer.CreateInstance(new GameServerConfig());
            GameServer.Instance.Start();
            GameServer.KeepRunning = true;

            Console.WriteLine("Server started!");
            ConsoleClient client = new ConsoleClient();
            while (GameServer.KeepRunning)
            {
                try
                {
                    handler = ConsoleCtrHandler;
                    SetConsoleCtrlHandler(handler, true);

                    Console.Write("> ");
                    string line = Console.ReadLine();
                    string[] para = line.Split(' ');
                    switch (para[0])
                    {
                        case "exit":
                            GameServer.KeepRunning = false;
                            break;
                        case "cp":
                            GameClient[] clients = GameServer.Instance.GetAllClients();
                            int clientCount = clients == null ? 0 : clients.Length;

                            GamePlayer[] players = WorldMgr.GetAllPlayers();
                            int playerCount = players == null ? 0 : players.Length;
                            List<BaseRoom> rooms = RoomMgr.GetAllUsingRoom();
                            int roomCount = 0;
                            int gameCount = 0;
                            foreach (BaseRoom r in rooms)
                            {
                                if (!r.IsEmpty)
                                {
                                    roomCount++;
                                    if (r.IsPlaying)
                                    {
                                        gameCount++;
                                    }
                                }
                            }

                            double memoryCount = GC.GetTotalMemory(false);
                            Console.WriteLine(string.Format("Total Clients/Players:{0}/{1}", clientCount, playerCount));
                            Console.WriteLine(string.Format("Total Rooms/Games:{0}/{1}", roomCount, gameCount));
                            Console.WriteLine(string.Format("Total Momey Used:{0} MB", memoryCount / 1024 / 1024));
                            break;
                        case "shutdown":

                            _count = 6;
                            //_timer = new Timer(new TimerCallback(GameServer.Instance.ShutDownCallBack), null, 0, 60 * 1000);
                            _timer = new Timer(new TimerCallback(ShutDownCallBack), null, 0, 60 * 1000);
                            break;
                        case "savemap":

                            //TODO:

                            break;
                        case "clear":
                            Console.Clear();
                            break;
                        case "ball&reload":
                            if (BallMgr.ReLoad())
                                Console.WriteLine("Ball info is Reload!");
                            else
                                Console.WriteLine("Ball info is Error!");
                            break;
                        case "map&reload":
                            if (MapMgr.ReLoadMap())
                                Console.WriteLine("Map info is Reload!");
                            else
                                Console.WriteLine("Map info is Error!");
                            break;
                        case "mapserver&reload":
                            if (MapMgr.ReLoadMapServer())
                                Console.WriteLine("mapserver info is Reload!");
                            else
                                Console.WriteLine("mapserver info is Error!");
                            break;
                        case "prop&reload":
                            if (PropItemMgr.Reload())
                                Console.WriteLine("prop info is Reload!");
                            else
                                Console.WriteLine("prop info is Error!");
                            break;
                        case "item&reload":
                            if (ItemMgr.ReLoad())
                                Console.WriteLine("item info is Reload!");
                            else
                                Console.WriteLine("item info is Error!");
                            break;
                        case "shop&reload":

                            if (ShopMgr.ReLoad())
                                Console.WriteLine("shop info is Reload!");
                            else
                                Console.WriteLine("shop info is Error!");
                            break;
                        case "quest&reload":
                            if (QuestMgr.ReLoad())
                                Console.WriteLine("quest info is Reload!");
                            else
                                Console.WriteLine("quest info is Error!");
                            break;
                        case "fusion&reload":
                            if (FusionMgr.ReLoad())
                                Console.WriteLine("fusion info is Reload!");
                            else
                                Console.WriteLine("fusion info is Error!");
                            break;
                        case "consortia&reload":
                            if (ConsortiaMgr.ReLoad())
                                Console.WriteLine("consortiaMgr info is Reload!");
                            else
                                Console.WriteLine("consortiaMgr info is Error!");
                            break;
                        case "rate&reload":
                            if (RateMgr.ReLoad())
                                Console.WriteLine("Rate Rate is Reload!");
                            else
                                Console.WriteLine("Rate Rate is Error!");
                            break;
                        case "fight&reload":
                            if (FightRateMgr.ReLoad())
                                Console.WriteLine("FightRateMgr is Reload!");
                            else
                                Console.WriteLine("FightRateMgr is Error!");
                            break;
                        case "dailyaward&reload":
                            if (AwardMgr.ReLoad())
                                Console.WriteLine("dailyaward is Reload!");
                            else
                                Console.WriteLine("dailyaward is Error!");
                            break;
                        case "language&reload":
                            if (LanguageMgr.Reload(""))
                                Console.WriteLine("language is Reload!");
                            else
                                Console.WriteLine("language is Error!");
                            break;
                        case "nickname":
                            Console.WriteLine("Please enter the nickname");
                            string nickname = Console.ReadLine();
                            string state = WorldMgr.GetPlayerStringByPlayerNickName(nickname);
                            Console.WriteLine(state);
                            break;
                        default:
                            if (line.Length <= 0) break;
                            if (line[0] == '/')
                            {
                                line = line.Remove(0, 1);
                                line = line.Insert(0, "&");
                            }

                            try
                            {
                                bool res = CommandMgr.HandleCommandNoPlvl(client, line);
                                if (!res)
                                {
                                    Console.WriteLine("Unknown command: " + line);
                                }
                            }
                            catch (Exception e)
                            {
                                Console.WriteLine(e.ToString());
                            }
                            break;
                    }

                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex);
                }
            }

            if (GameServer.Instance != null)
                GameServer.Instance.Stop();

            LogManager.Shutdown();
        }
Beispiel #21
0
 internal CriticalCtrlHandler()
 {
     consoleCtrlDelegate = new ConsoleCtrlDelegate(ConsoleCtrlCheck);
     ok = SetConsoleCtrlHandler(consoleCtrlDelegate, true);
 }
Beispiel #22
0
 public bool SetConsoleCtrlHandler(ConsoleCtrlDelegate handlerRoutine, bool add) => Api.SetConsoleCtrlHandler(handlerRoutine, add);
Beispiel #23
0
 private static extern bool SetConsoleCtrlHandler(ConsoleCtrlDelegate e, bool add);
Beispiel #24
0
 private static extern bool SetConsoleCtrlHandler(ConsoleCtrlDelegate HandlerRoutine, bool Add);
Beispiel #25
0
 public static extern bool SetConsoleCtrlHandler(ConsoleCtrlDelegate handler, bool add);
Beispiel #26
0
 public static void UnregisterHandler([NotNull] ConsoleCtrlDelegate handler)
 {
     Win32.SetConsoleCtrlHandler(handler, false);
 }
Beispiel #27
0
 private static extern bool SetConsoleCtrlHandler(ConsoleCtrlDelegate HandlerRoutine, bool Add);
Beispiel #28
0
        public static bool SetConsoleCtrlHandler(ConsoleCtrlDelegate handlerRoutine, bool add)
        {
            switch (PlatformIdentifier)
            {
                case PlatformID.Win32NT:
                    return Win32SetConsoleCtrlHandler(handlerRoutine, add);

                default:
                    return true;
            }
        }