コード例 #1
0
        public static IAsyncResult Current(CurrentTrendsOptions options, TimeSpan timeout, Action<TwitterAsyncResponse<TwitterTrendCollection>> function)
        {
#if !SILVERLIGHT
            Func<CurrentTrendsOptions, TwitterResponse<TwitterTrendCollection>> methodToCall = TwitterTrend.Current;

            return methodToCall.BeginInvoke(
                options,
                result =>
                {
                    result.AsyncWaitHandle.WaitOne(timeout);
                    try
                    {
                        function(methodToCall.EndInvoke(result).ToAsyncResponse());
                    }
                    catch (Exception ex)
                    {
                        function(new TwitterAsyncResponse<TwitterTrendCollection>() { Result = RequestResult.Unknown, ExceptionThrown = ex });
                    }
                },
                null);
#else            
            ThreadPool.QueueUserWorkItem((x) =>
                {
                    function(TwitterTrend.Current(options).ToAsyncResponse<TwitterTrendCollection>());  
                });
            return null;
#endif
        }
コード例 #2
0
        public static IAsyncResult Current(CurrentTrendsOptions options, TimeSpan timeout, Action<TwitterAsyncResponse<TwitterTrendCollection>> function)
        {
            Func<CurrentTrendsOptions, TwitterResponse<TwitterTrendCollection>> methodToCall = TwitterTrend.Current;

            return methodToCall.BeginInvoke(
                options,
                result =>
                {
                    result.AsyncWaitHandle.WaitOne(timeout);
                    try
                    {
                        function(methodToCall.EndInvoke(result).ToAsyncResponse());
                    }
                    catch (Exception ex)
                    {
                        function(new TwitterAsyncResponse<TwitterTrendCollection>() { Result = RequestResult.Unknown, ExceptionThrown = ex });
                    }
                },
                null);
        }
コード例 #3
0
        /// <summary>
        /// Gets the current trends.
        /// </summary>
        /// <param name="options">The options.</param>
        /// <returns>
        /// A collection of <see cref="Twitterizer.TwitterTrend"/> objects.
        /// </returns>
        public static TwitterResponse<TwitterTrendCollection> Current(CurrentTrendsOptions options)
        {
            Commands.CurrentTrendsCommand command = new Twitterizer.Commands.CurrentTrendsCommand(options);

            return Core.CommandPerformer<TwitterTrendCollection>.PerformAction(command);
        }