/// <summary> /// Worker thread that handles the new mouse event tasks /// </summary> private void HandleMouseInput() { try { mouseLogger.Info("Inside Mouse thread."); int searchResult = gameOperation.SearchRunningGame(gameName); if (searchResult != (int)ResultCodes.Success) { this.mouseLogger.Fatal("Game interested: " + gameName + "is not running"); this.threadExit = true; return; } gameInfo = gameOperation.GameSetFocus(gameName); do { handleRequests.WaitOne(); int queueCount = GetQueueCount(); if (queueCount > 0) { MouseData newMouseInput = RemoveFromQueue(); mouseLogger.Debug("Removed data from queue -:"); mouseLogger.Debug("key = " + newMouseInput.MouseAction + " , Persistance = " + newMouseInput.KeyPersistance); ProcessMouseInput(newMouseInput); } } while (!threadExit); } catch (Exception ex) { mouseLogger.Fatal("Exception in Keyboard handler thread = " + ex.Message); } }
/// <summary> /// Main worker thread that handles all the new data arriving /// </summary> private void HandleKeyBoardInput() { try { keyboardLogger.Info("Inside Keyboard thread."); keyboardLogger.Info("Searching for the game interested: " + gameName); int searchResult = gameOperation.SearchRunningGame(gameName); if (searchResult != (int)ResultCodes.Success) { keyboardLogger.Fatal("Game interested: " + gameName + "is not running"); this.threadExit = true; return; } keyboardLogger.Debug("Game interested: " + gameName + " has been found"); keyboardLogger.Info("Setting the focus to the game: " + gameName); gameInfo = gameOperation.GameSetFocus(gameName); if (gameInfo == null) { keyboardLogger.Fatal("Failed to set the focus of the game!!!!!!!"); return; } keyboardLogger.Info("Focus to the game successfully set."); do { handleRequests.WaitOne(); int queueCount = GetQueueCount(); if (queueCount > 0) { KeyboardData newKeyboardInput = RemoveFromQueue(); keyboardLogger.Debug("Removed data from queue -:"); keyboardLogger.Debug("key = " + newKeyboardInput.KeyboardAction + " , Persistance = " + newKeyboardInput.KeyPersistance); ProcessKeyboardInput(newKeyboardInput); } } while (!threadExit); } catch (Exception ex) { keyboardLogger.Fatal("Exception in Keyboard handler thread = " + ex.Message); } }