コード例 #1
0
        /// <summary>
        /// Begin listening for message events from the server.
        /// </summary>
        private async Task beginFetchingMessages()
        {
            while (keepFetchingMessages)
            {
                try
                {
                    //Get channel events
                    //When calling await, control is passed back to the caller, so this while loop does not block the UI thread
                    IEnumerable <ChannelEventDTO> channelEvents =
                        await channelsApi.GetChannelEventsAsync((int)currentChannelId, latestEventTime, messageFetchCancellation.Token);

                    handleChannelEvents(channelEvents, messageFetchCancellation.Token);
                }
                catch (TaskCanceledException)
                {
                    Console.WriteLine("The live message fetch task was canceled");
                }
                catch (HttpOperationException er)
                {
                    new ErrorDialog(er.Response.ReasonPhrase, er.Response.Content).ShowDialog();
                }
            }
        }
コード例 #2
0
 /// <summary>
 /// Wait for and get new messages, message deletions, message edits, channel
 /// information updates, and channel deletions in a channel
 /// </summary>
 /// <remarks>
 /// This request will not return from the service until at least one new
 /// channel event has occurred
 /// </remarks>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='channelId'>
 /// The id of the channel to listen to
 /// </param>
 /// <param name='since'>
 /// The time to get channel events since
 /// </param>
 public static IList <ChannelEventDTO> GetChannelEvents(this IChannels operations, int channelId, System.DateTime since)
 {
     return(operations.GetChannelEventsAsync(channelId, since).GetAwaiter().GetResult());
 }