示例#1
0
        /// <summary>
        /// Add a screenshot request
        /// </summary>
        /// <param name="clientPID"></param>
        /// <param name="screenshotRequest"></param>
        /// <param name="responseNotification"></param>
        public static void AddScreenshotRequest(Int32 clientPID, ScreenshotRequest screenshotRequest, ScreenshotRequestResponseNotification responseNotification)
        {
            try
            {
                if (!HookManager.HookedProcesses.Contains(clientPID))
                {
                    throw new ArgumentException("The client process must be hooked first", "clientPID");
                }
                if (screenshotRequest == null)
                {
                    throw new ArgumentNullException("screenshotRequest");
                }
                if (responseNotification == null)
                {
                    throw new ArgumentNullException("responseNotification");
                }

                lock (_screenshotRequestByClientPID)
                {
                    lock (_screenshotRequestNotifications)
                    {
                        _screenshotRequestByClientPID[clientPID] = screenshotRequest;
                        _screenshotRequestNotifications[clientPID] = responseNotification;
                    }
                }
            }
            catch
            {
            }
        }
示例#2
0
 public static ScreenshotResponse GetScreenshotSynchronous(Int32 clientPID, ScreenshotRequest screenshotRequest)
 {
     // 2 second timeout
     return GetScreenshotSynchronous(clientPID, screenshotRequest, new TimeSpan(0, 0, 2));
 }
示例#3
0
        public static ScreenshotResponse GetScreenshotSynchronous(Int32 clientPID, ScreenshotRequest screenshotRequest, TimeSpan timeout)
        {
            object srLock = new object();
            ScreenshotResponse sr = null;

            ScreenshotRequestResponseNotification srrn = delegate(Int32 cPID, ResponseStatus status, ScreenshotResponse screenshotResponse)
            {
                Interlocked.Exchange(ref sr, screenshotResponse);
            };
            DateTime startRequest = DateTime.Now;
            AddScreenshotRequest(clientPID, screenshotRequest, srrn);

            // Wait until the response has been returned
            while (true)
            {
                Thread.Sleep(10);

                if (sr != null)
                {
                    break;
                }

                // Break if timed out (will result in a null return value)
                if (DateTime.Now - startRequest > timeout)
                {
                    return null;
                }
            }

            return sr;
        }
示例#4
0
 public static ScreenshotResponse GetScreenshotSynchronous(Int32 clientPID, ScreenshotRequest screenshotRequest)
 {
     // 2 second timeout
     return(GetScreenshotSynchronous(clientPID, screenshotRequest, new TimeSpan(0, 0, 2)));
 }