示例#1
0
        public void Queue(string strText, PwListItem li, int iIndexHint,
                          int iSubItem, PwTextUpdateDelegate f)
        {
            if (strText == null)
            {
                Debug.Assert(false); return;
            }
            if (li == null)
            {
                Debug.Assert(false); return;
            }
            if (iSubItem < 0)
            {
                Debug.Assert(false); return;
            }
            if (f == null)
            {
                Debug.Assert(false); return;
            }

            LviUpdInfo state = new LviUpdInfo();

            state.ListView           = m_lv;
            state.UpdateID           = unchecked ((li.ListViewItemID << 6) + iSubItem);
            state.Text               = strText;
            state.ListItem           = li;
            state.IndexHint          = ((iIndexHint >= 0) ? iIndexHint : 0);
            state.SubItem            = iSubItem;
            state.Function           = f;
            state.ListEditSyncObject = m_objListEditSync;
            state.ValidIDsSyncObject = m_objValidIDsSync;
            state.ValidIDs           = m_dValidIDs;

            lock (m_objValidIDsSync)
            {
                Debug.Assert(!m_dValidIDs.ContainsKey(state.UpdateID));
                m_dValidIDs[state.UpdateID] = true;
            }

            try
            {
                if (!ThreadPool.QueueUserWorkItem(new WaitCallback(UpdateItemFn),
                                                  state))
                {
                    throw new InvalidOperationException();
                }
            }
            catch (Exception)
            {
                Debug.Assert(false);
                lock (m_objValidIDsSync) { m_dValidIDs.Remove(state.UpdateID); }
            }
        }
		public void Queue(string strText, PwListItem li, int iIndexHint,
			int iSubItem, PwTextUpdateDelegate f)
		{
			if(strText == null) { Debug.Assert(false); return; }
			if(li == null) { Debug.Assert(false); return; }
			if(iSubItem < 0) { Debug.Assert(false); return; }
			if(f == null) { Debug.Assert(false); return; }

			LviUpdInfo state = new LviUpdInfo();
			state.ListView = m_lv;
			state.UpdateID = unchecked((li.ListViewItemID << 6) + iSubItem);
			state.Text = strText;
			state.ListItem = li;
			state.IndexHint = ((iIndexHint >= 0) ? iIndexHint : 0);
			state.SubItem = iSubItem;
			state.Function = f;
			state.ListEditSyncObject = m_objListEditSync;
			state.ValidIDsSyncObject = m_objValidIDsSync;
			state.ValidIDs = m_dValidIDs;

			lock(m_objValidIDsSync)
			{
				Debug.Assert(!m_dValidIDs.ContainsKey(state.UpdateID));
				m_dValidIDs[state.UpdateID] = true;
			}

			try
			{
				if(!ThreadPool.QueueUserWorkItem(new WaitCallback(UpdateItemFn),
					state)) throw new InvalidOperationException();
			}
			catch(Exception)
			{
				Debug.Assert(false);
				lock(m_objValidIDsSync) { m_dValidIDs.Remove(state.UpdateID); }
			}
		}