KeePass.UI.AsyncPwListUpdate.UpdateItemFn C# (CSharp) Method

UpdateItemFn() private static method

private static UpdateItemFn ( object state ) : void
state object
return void
        private static void UpdateItemFn(object state)
        {
            LviUpdInfo lui = (state as LviUpdInfo);
            if(lui == null) { Debug.Assert(false); return; }

            try // Avoid cross-thread exceptions
            {
                bool bWork;
                lock(lui.ValidIDsSyncObject)
                {
                    if(!lui.ValidIDs.TryGetValue(lui.UpdateID,
                        out bWork)) { Debug.Assert(false); return; }
                }

                if(bWork)
                {
                    string strNew = lui.Function(lui.Text, lui.ListItem);
                    if(strNew == null) { Debug.Assert(false); return; }
                    if(strNew == lui.Text) return;

                    // if(lui.ListView.InvokeRequired)
                    lui.ListView.Invoke(new SetItemTextDelegate(
                        SetItemText), new object[] { strNew, lui });
                    // else SetItemText(strNew, lui);
                }
            }
            catch(Exception) { Debug.Assert(false); }
            finally
            {
                try // Avoid cross-thread exceptions
                {
                    lock(lui.ValidIDsSyncObject)
                    {
                        if(!lui.ValidIDs.Remove(lui.UpdateID)) { Debug.Assert(false); }
                    }
                }
                catch(Exception) { Debug.Assert(false); }
            }
        }