Exemplo n.º 1
0
        public void Start()
        {
            lock (_locker)
            {
                if (!_isRunning)
                {
                    _prevTimeApplication         = DateTime.Now;
                    _activeWindows               = new Dictionary <IntPtr, WindowInfoObject>();
                    _taskCancellationTokenSource = new CancellationTokenSource();
                    _applicationsQueue           = new QueueHookConcurrentAsync <object>(_taskCancellationTokenSource.Token);

                    Task.Factory.StartNew(() =>
                    {
                        _eventHook = new WindowEventHook(_shf);
                        _eventHook.WindowCreated   += WindowCreated;
                        _eventHook.WindowDestroyed += WindowDestroyed;
                        _eventHook.WindowActivated += WindowActivated;
                    },
                                          CancellationToken.None,
                                          TaskCreationOptions.None,
                                          _shf.GetTaskScheduler()).Wait();

                    _lastEventWasLaunched = false;
                    _lastHwndLaunched     = IntPtr.Zero;

                    Task.Factory.StartNew(ApplicationConsumer);
                    _isRunning = true;
                }
            }
        }
        public void Start()
        {
            lock (_locker)
            {
                if (!_isRunning)
                {
                    _taskCancellationTokenSource = new CancellationTokenSource();
                    _keyQueue = new QueueHookConcurrentAsync <object>(_taskCancellationTokenSource.Token);

                    Task.Factory.StartNew(() =>
                    {
                        _keyboardEventHook          = new KeyboardEventHook();
                        _keyboardEventHook.KeyDown += KeyGeter;
                        _keyboardEventHook.KeyUp   += KeyGeter;
                        _keyboardEventHook.Start();
                    },
                                          CancellationToken.None,
                                          TaskCreationOptions.None,
                                          _shf.GetTaskScheduler()).Wait();

                    Task.Factory.StartNew(ConsumeKeyAsync);

                    _isRunning = true;
                }
            }
        }
 public void Start()
 {
     lock (accesslock)
     {
         if (!isRunning)
         {
             Task.Factory.StartNew(() =>
             {
                 isRunning   = true;
                 printers    = new ArrayList();
                 printServer = new PrintServer();
                 foreach (var pq in printServer.GetPrintQueues())
                 {
                     var pqm = new PrintQueueHook(pq.Name);
                     pqm.OnJobStatusChange += pqm_OnJobStatusChange;
                     pqm.Start();
                     printers.Add(pqm);
                 }
             },
                                   CancellationToken.None,
                                   TaskCreationOptions.None,
                                   factory.GetTaskScheduler()).Wait();
         }
     }
 }
        public void Start()
        {
            lock (_locker)
            {
                if (!IsRunning)
                {
                    _taskCancellationTokenSource = new CancellationTokenSource();
                    _clipQueue = new QueueHookConcurrentAsync <object>(_taskCancellationTokenSource.Token);

                    Task.Factory.StartNew(() =>
                    {
                        _clipBoard = new ClipBoardEventHook();
                        _clipBoard.RegisterClipboardViewer();
                        _clipBoard.ClipBoardChanged += ClipboardHandler;
                    },
                                          CancellationToken.None,
                                          TaskCreationOptions.None,
                                          _shf.GetTaskScheduler()).Wait();

                    Task.Factory.StartNew(ClipConsumerAsync);

                    IsRunning = true;
                }
            }
        }
        public void Start()
        {
            lock (_locker)
            {
                if (!_isRunning)
                {
                    _taskCancellationTokenSource = new CancellationTokenSource();
                    _mouseQueue = new QueueHookConcurrentAsync <object>(_taskCancellationTokenSource.Token);
                    Task.Factory.StartNew(() =>
                    {
                        _mouseHook              = new MouseEventHook();
                        _mouseHook.MouseAction += MouseGetter;
                        _mouseHook.Start();
                    },
                                          CancellationToken.None,
                                          TaskCreationOptions.None,
                                          _shf.GetTaskScheduler()).Wait();

                    Task.Factory.StartNew(() => ConsumeKeyAsync());

                    _isRunning = true;
                }
            }
        }