Beispiel #1
0
        /// <summary>
        /// Initiates the asynchronous execution of the method that is referenced by the ProcessDelagate delegate.
        /// </summary>
        /// <param name="process">The delegate that invokes the asynchronous method</param>
        /// <param name="response">The current widget response</param>
        /// <param name="parms">An array of objects to pass as arguments to the given method. Null if no arguments are needed</param>
        /// <param name="timeoutMS">The number of seconds an asynchronous method can run before timing out</param>
        /// <param name="hearbit">The number of seconds between polls to determine if the asynchronous method is done processing</param>
        public static LongRunningTaskStatus ClientWaitServerProcess(LongRunningTaskDelegate process, Sevens events, object[] parms, int timeout, int heartbeat)
        {
            if (process == null || events == null)
            {
                throw new ArgumentNullException("Delegate object could not be null");
            }

            if (heartbeat < 5000)
            {
                heartbeat = 5000;
            }

            List <LongRunningTaskDelegate> delegates = GetDelegateList(true);

            if (delegates.Count > 23)
            {
                return(LongRunningTaskStatus.QueueIsFull);
            }

            string methodGuid = Guid.NewGuid().ToString("N");

            delegates.Add(process);

            Sevens        callbackResponse = new Sevens();
            AsyncCallback callback         = new AsyncCallback(WaitServerCallback);

            TaskState state = new TaskState(process, callbackResponse, methodGuid);

            process.BeginInvoke(callbackResponse, parms, callback, state);

            return(LongRunningTaskStatus.Queued);
        }
Beispiel #2
0
 public TaskState(LongRunningTaskDelegate method, Sevens sevens, string methodGuid)
 {
     Delegate   = method;
     Sevens     = sevens;
     MethodGuid = methodGuid;
 }
        /// <summary>
        /// Initiates the asynchronous execution of the method that is referenced by the ProcessDelagate delegate.
        /// </summary>
        /// <param name="process">The delegate that invokes the asynchronous method</param>
        /// <param name="response">The current widget response</param>
        /// <param name="parms">An array of objects to pass as arguments to the given method. Null if no arguments are needed</param>
        /// <param name="timeoutMS">The number of seconds an asynchronous method can run before timing out</param>
        /// <param name="hearbit">The number of seconds between polls to determine if the asynchronous method is done processing</param>
        public static LongRunningTaskStatus ClientWaitServerProcess(LongRunningTaskDelegate process, Sevens events, object[] parms, int timeout, int heartbeat) {
            if (process == null || events == null)
                throw new ArgumentNullException("Delegate object could not be null");

            if (heartbeat < 5000)
                heartbeat = 5000;

            List<LongRunningTaskDelegate> delegates = GetDelegateList(true);
            if (delegates.Count > 23)
                return LongRunningTaskStatus.QueueIsFull;

            string methodGuid = Guid.NewGuid().ToString("N");

            delegates.Add(process);

            Sevens callbackResponse = new Sevens();
            AsyncCallback callback = new AsyncCallback(WaitServerCallback);

            TaskState state = new TaskState(process, callbackResponse, methodGuid);
            process.BeginInvoke(callbackResponse, parms, callback, state);

            return LongRunningTaskStatus.Queued;
        }
 public TaskState(LongRunningTaskDelegate method, Sevens sevens, string methodGuid)
 {
     Delegate = method;
     Sevens = sevens;
     MethodGuid = methodGuid;
 }