Exemple #1
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="browser"></param>
        /// <param name="service"></param>
        /// <param name="moreComing"></param>
        void nsBrowser_DidRemoveService(NetServiceBrowser browser, NetService service, bool moreComing) {
            ArrayList itemsToRemove = new ArrayList();

#if PLAYER_TASKBAR
            foreach (MenuItem item in streamersItem.MenuItems) {
                if (item.Tag == service)
                    itemsToRemove.Add(item);
            }

            foreach (MenuItem item in itemsToRemove) {
                streamersItem.MenuItems.Remove(item);

                while (true) {
                    Streamer toDelete = null;

                    foreach (Streamer strm in streamers) {
                        if (strm.id.Equals(service.Name)) {
                            strm.Close();
                            toDelete = strm;
                            break;
                        }
                    }

                    if (toDelete != null)
                        streamers.Remove(toDelete);
                    else
                        break;
                }
            }

            itemsToRemove.Clear();
#else
            browserList.BeginUpdate();
            
            foreach (ListViewItem item in browserList.Items) {
                if (item.Tag == service)
                    itemsToRemove.Add(item);
            }
            
            foreach (ListViewItem item in itemsToRemove) {
                browserList.Items.Remove(item);

                while (true) {
                    Streamer toDelete = null;

                    foreach (Streamer strm in streamers) {
                        if (strm.id.Equals(service.Name)) {
                            strm.Close();
                            toDelete = strm;
                            break;
                        }
                    }

                    if (toDelete != null)
                        streamers.Remove(toDelete);
                    else
                        break;
                }
            }

            itemsToRemove.Clear();
            browserList.EndUpdate();
#endif
            service.Dispose();
        }
        void nsBrowser_DidRemoveService(NetServiceBrowser browser, NetService service, bool moreComing)
        {
            Debug.WriteLine(String.Format("{0}: nsBrowser_DidRemoveService: {1}", System.Threading.Thread.CurrentThread.ManagedThreadId, service.Name));

            servicesList.BeginUpdate();
            foreach (ListViewItem item in servicesList.Items)
            {
                if (item.Tag == service)
                    servicesList.Items.Remove(item);
            }
            servicesList.EndUpdate();

            service.Dispose();
        }