Exemple #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);
        }
Exemple #2
0
        /// <summary>
        /// Creates a deep copy of the Sevens.
        /// </summary>
        /// <returns>A deep copy of the Sevens</returns>
        public object Clone()
        {
            Sevens clone = new Sevens(sevens_.Count);

            string[] sevens = sevens_.ToArray();
            for(int i=0,j=sevens.Length;i<j;i++) {
                clone.sevens_.Enqueue(sevens[i]);
            }
            return clone;
        }
Exemple #3
0
        /// <summary>
        /// Creates a deep copy of the Sevens.
        /// </summary>
        /// <returns>A deep copy of the Sevens</returns>
        public object Clone()
        {
            Sevens clone = new Sevens(sevens_.Count);

            string[] sevens = sevens_.ToArray();
            for (int i = 0, j = sevens.Length; i < j; i++)
            {
                clone.sevens_.Enqueue(sevens[i]);
            }
            return(clone);
        }
Exemple #4
0
        public static Sevens GetResults(string key, int heartbeat)
        {
            Sevens events = null;

            lock (dataStore.SyncRoot) {
                events = (Sevens)dataStore[key];
                if (events != null)
                {
                    dataStore.Remove(key);
                }
            }
            return(events);
        }
Exemple #5
0
        /// <summary>
        /// Merges the specified Sevens object into the current Sevens object.
        /// </summary>
        /// <param name="response">The Sevens object to be merged into the current Sevens object</param>
        public Sevens Merge(Sevens sevens)
        {
            if (sevens == null)
                throw new ArgumentNullException("sevens");

            if( this.Equals(sevens) )
                return this;

            string[] sevens_str = sevens_.ToArray();
            for (int i = 0, j = sevens_str.Length; i < j; i++) {
                sevens_.Enqueue(sevens_str[i]);
            }

            return this;
        }
Exemple #6
0
        /// <summary>
        /// Merges the specified Sevens object into the current Sevens object.
        /// </summary>
        /// <param name="response">The Sevens object to be merged into the current Sevens object</param>
        public Sevens Merge(Sevens sevens)
        {
            if (sevens == null)
            {
                throw new ArgumentNullException("sevens");
            }

            if (this.Equals(sevens))
            {
                return(this);
            }

            string[] sevens_str = sevens_.ToArray();
            for (int i = 0, j = sevens_str.Length; i < j; i++)
            {
                sevens_.Enqueue(sevens_str[i]);
            }

            return(this);
        }
Exemple #7
0
 static void SetResult(string key, Sevens sevens)
 {
     lock (dataStore.SyncRoot) {
         dataStore.Add(key, sevens);
     }
 }
Exemple #8
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;
        }
 static void SetResult(string key, Sevens sevens) {
     lock (dataStore.SyncRoot) {
         dataStore.Add(key, sevens);
     }
 }
 public TaskState(LongRunningTaskDelegate method, Sevens sevens, string methodGuid)
 {
     Delegate = method;
     Sevens = sevens;
     MethodGuid = methodGuid;
 }