Ejemplo n.º 1
0
        public ExecutionResult Execute(GestureContext context, GestureParser gestureParser)
        {
            //Aware接口依赖注入
            var contextAware = Command as IGestureContextAware;
            if (contextAware != null) contextAware.Context = context;

            var parserAware = this.Command as IGestureParserAware;
            if (parserAware != null) parserAware.Parser = gestureParser;

            //在独立线程中运行
            //new Thread似乎反应快一点,ThreadPool似乎有延迟
            //ThreadPool.QueueUserWorkItem((s) =>
            //new Thread(() =>
            {
                try
                {
                    context.ActivateTargetWindow();
                    Command.Execute();
                }
                catch (Exception)
                {
                    //ignore errors for now
            #if DEBUG
                    throw;
            #endif
                }
            }//) { IsBackground = false}.Start();

            return new ExecutionResult(null, true);
        }
Ejemplo n.º 2
0
        public ExecutionResult Execute(GestureContext context, GestureParser gestureParser)
        {
            //Aware接口依赖注入
            var contextAware = Command as IGestureContextAware;

            if (contextAware != null)
            {
                contextAware.Context = context;
            }

            var parserAware = this.Command as IGestureParserAware;

            if (parserAware != null)
            {
                parserAware.Parser = gestureParser;
            }

            //var intentStoreAware = Command as IGestureIntentStoreAware;
            //if (intentStoreAware != null) intentStoreAware.IntentStore = null;


            var shouldInit = this.Command as INeedInit;

            if (shouldInit != null && !shouldInit.IsInitialized)
            {
                shouldInit.Init();
            }

            //在独立线程中运行
            //new Thread似乎反应快一点,ThreadPool似乎有延迟
            //ThreadPool.QueueUserWorkItem((s) =>
            //new Thread(() =>
            {
                try
                {
                    context.ActivateTargetWindow();
                    Command.Execute();
                    using (var proc = Process.GetCurrentProcess())
                    {
                        Native.SetProcessWorkingSetSize(proc.Handle, -1, -1);
                    }
                }
                catch (Exception)
                {
                    //ignore errors for now
#if DEBUG
                    throw;
#endif
                }
            }//) { IsBackground = false}.Start();

            return(new ExecutionResult(null, true));
        }
Ejemplo n.º 3
0
        public ExecutionResult Execute(GestureContext context, GestureParser gestureParser)
        {
            //Aware接口依赖注入
            var contextAware = Command as IGestureContextAware;
            if (contextAware != null) contextAware.Context = context;

            var parserAware = this.Command as IGestureParserAware;
            if (parserAware != null) parserAware.Parser = gestureParser;

            var shouldInit = this.Command as INeedInit;
            if (shouldInit != null && !shouldInit.IsInitialized)
            {
                shouldInit.Init();
            }
            
            //在独立线程中运行
            //new Thread似乎反应快一点,ThreadPool似乎有延迟
            //ThreadPool.QueueUserWorkItem((s) =>
            //new Thread(() =>
            {
                try
                {
                    context.ActivateTargetWindow();
                    Command.Execute();
                    using (var proc = Process.GetCurrentProcess())
                    {
                        Native.SetProcessWorkingSetSize(proc.Handle, -1, -1);
                    }
                }
                catch (Exception)
                {
                    //ignore errors for now
#if DEBUG
                    throw;
#endif
                }
            }//) { IsBackground = false}.Start();

            return new ExecutionResult(null, true);

        }
Ejemplo n.º 4
0
        public ExecutionResult Execute(GestureContext context, GestureParser gestureParser)
        {
            //Aware接口依赖注入
            var contextAware = Command as IGestureContextAware;

            if (contextAware != null)
            {
                contextAware.Context = context;
            }

            var parserAware = this.Command as IGestureParserAware;

            if (parserAware != null)
            {
                parserAware.Parser = gestureParser;
            }


            //在独立线程中运行
            //new Thread似乎反应快一点,ThreadPool似乎有延迟
            //ThreadPool.QueueUserWorkItem((s) =>
            //new Thread(() =>
            {
                try
                {
                    context.ActivateTargetWindow();
                    Command.Execute();
                }
                catch (Exception)
                {
                    //ignore errors for now
#if DEBUG
                    throw;
#endif
                }
            }//) { IsBackground = false}.Start();

            return(new ExecutionResult(null, true));
        }