示例#1
0
        /// <summary>A wrapper over DispatchSync that calls a value-producing function and returns it's result</summary>
        /// <typeparam name="T">Result type</typeparam>
        /// <param name="queue">The queue to execute the function on</param>
        /// <param name="func">The function to execute</param>
        /// <returns>The return value of func</returns>
        public static T DispatchSync <T>(this IDispatchQueue queue, Func <T> func)
        {
            T result = default(T);

            queue.DispatchSync(() => { result = func(); });
            return(result);
        }