Beispiel #1
0
        /// <summary>
        /// Initiates an asynchronous call of the specified method with the specified parameters.
        /// </summary>
        /// <param name="method">The method to call.</param>
        /// <param name="parameters">The parameters to use when calling the method.</param>
        public static void Call(AsyncMethod method, params object[] parameters)
        {
            if (method == null)
            {
                throw new ArgumentException("Invalid method specified!");
            }

            var asyncCall = new AsyncCall()
            {
                Method = method, Parameters = parameters
            };

            if (ThreadPool.QueueUserWorkItem(new WaitCallback(ExecuteAsyncCall), asyncCall) == false)
            {
                asyncCall.Error("Asynchronous execution of method '{0}' failed!", method.Method.Name);
            }
        }