void OnChatSynced(object sender, ChatViewSyncedEventArgs e) { Trace.Call(sender, e); // FIXME: should we tell the FrontendManager before we sync? // no problem making remoting calls here as this event is called // from worker threads // REMOTING CALL 1 Frontend.FrontendManager.AddSyncedChat(e.ChatView.ChatModel); GLib.Idle.Add(delegate { var chatView = (ChatView)e.ChatView; // we need to bailt out in case the chat was closed during the sync // else chatView.Populate() will die hard, see #635 if (!Chats.Contains(chatView)) { #if LOG4NET f_Logger.Debug("OnChatSynced(): detected closed chat: " + chatView.ID + " during sync, bailing out..."); #endif return(false); } // HACK: patch chat position as OnChatAdded is not honoring the // AddChat order nor the complete range of chats if (chatView.Position != -1) { f_Notebook.ReorderChild(chatView, chatView.Position); } #if LOG4NET DateTime start = DateTime.UtcNow; #endif chatView.Populate(); #if LOG4NET DateTime stop = DateTime.UtcNow; double duration = stop.Subtract(start).TotalMilliseconds; f_Logger.Debug("OnChatSynced(): " + "<" + chatView.ID + ">.Populate() " + "Position: " + chatView.Position + " done, took: " + Math.Round(duration) + " ms"); #endif chatView.ScrollToEnd(); SyncedChats.Add(chatView); if (ChatSynced != null) { ChatSynced(this, new ChatViewManagerChatSyncedEventArgs(chatView)); } return(false); }); }