예제 #1
0
        private void btnMonitorCacheItem_Click(object sender, EventArgs e)
        {
            string key = txtMonitorItem.Text.Trim();

            if (myCache == null)
            {
                UpdateStatus("First click Connect To Cache");
                return;
            }

            if (key.Length < 1)
            {
                MessageBox.Show("You must enter at least 1 valid key to montior.");
                return;
            }


            try
            {
                DataCacheNotificationDescriptor dcnd = myCache.AddItemLevelCallback(key,
                                                                                    DataCacheOperations.AddItem | DataCacheOperations.RemoveItem | DataCacheOperations.ReplaceItem,
                                                                                    DataCacheItemCallBackHandler);

                callbacks.Add(dcnd);

                //lstboxMontiorItemHistory.Items.Add("Time: " + DateTime.Now.ToLongTimeString() + " Key: " + key + " has been added to monitor list");
                rtbMontiorCache.AppendText("\r" + "Time: " + DateTime.Now.ToLongTimeString() + " Key: " + key + " has been added to monitor list");

                UpdateStatus("Setup ItemLevelCallBack for Item.");
            }
            catch (Exception ex)
            {
                HandleException(ex);
            }
        }