Example #1
0
        public void loadChat()
        {
            bool completed = false;
            using (WebClientTimeOut wc = new WebClientTimeOut(2000))
            {

                wc.Headers.Add("user-agent", "BlitzChat");
                wc.DownloadStringCompleted += delegate(object a, DownloadStringCompletedEventArgs b)
                {
                    if (b.Error == null)
                    {
                        try
                        {
                            JObject messages = JsonConvert.DeserializeObject<JObject>(b.Result);
                            if (messages != null)
                            {
                                updateMessages(messages);
                            }
                        }
                        catch (Exception e)
                        {
                            Debug.Print("Chat messages deserializing exception: " + e.Message);
                        }
                    }
                    completed = true;
                };
                wc.DownloadStringAsync(new Uri(string.Format(chatUrl, chatId)));
                while (!completed) { 
                    
                    Thread.Sleep(20); 
                }

            }
        }