示例#1
0
        public ResourceCounter fetchResourceCounter(string resourceName, int period)
        {
            Monitor.Enter(this);
            ResourceCounter result;

            try
            {
                if (!resourceCountersByName.ContainsKey(resourceName))
                {
                    resourceCountersByName[resourceName] = new ResourceCounter(resourceName,
                                                                               period,
                                                                               ResourceCounterCallback);
                    if (canInvoke)
                    {
                        DebugThreadInterrupter.theInstance.AddThread("DiagnosticUI.CreateAllCountersInvokeThread",
                                                                     CreateAllCountersInvokeThread,
                                                                     ThreadPriority.Normal);
                    }
                }

                result = resourceCountersByName[resourceName];
            }
            finally
            {
                Monitor.Exit(this);
            }

            return(result);
        }
示例#2
0
		public DiskCache()
		{
			this.cacheDir = Path.Combine(Environment.GetEnvironmentVariable("TMP"), "mapcache\\");
			this.stableFreshCountPathname = Path.Combine(this.cacheDir, "FreshCount.txt");
			this.CreateCacheDirIfNeeded();
			DebugThreadInterrupter.theInstance.AddThread("DiskCache.DeferredWriteThread", new ThreadStart(this.DeferredWriteThread), ThreadPriority.Normal);
			DebugThreadInterrupter.theInstance.AddThread("DiskCache.EvictThread", new ThreadStart(this.EvictThread), ThreadPriority.Normal);
			this.resourceCounter = DiagnosticUI.theDiagnostics.fetchResourceCounter("DiskCache", -1);
		}
示例#3
0
 private void ResourceCounterCallback(ResourceCounter resourceCounter)
 {
     if (canInvoke)
     {
         try
         {
             resourceCounterToGridRow[resourceCounter].Cells[1].Value = resourceCounter.Value;
         }
         catch (KeyNotFoundException)
         {
         }
     }
 }
示例#4
0
 private void CreateAllCounters()
 {
     foreach (string current in resourceCountersByName.Keys)
     {
         ResourceCounter resourceCounter = resourceCountersByName[current];
         if (!resourceCounterToGridRow.ContainsKey(resourceCounter))
         {
             int             index           = resourceCountersGridView.Rows.Add();
             DataGridViewRow dataGridViewRow = resourceCountersGridView.Rows[index];
             dataGridViewRow.Cells[0].Value = current;
             dataGridViewRow.Cells[1].Value = resourceCounter.Value;
             resourceCounterToGridRow.Add(resourceCounter, dataGridViewRow);
         }
     }
 }
示例#5
0
		public MemoryCache(string debugName) : base(debugName)
		{
			this.clockQueue = new LinkedList<CacheRecord>();
			this.interestingStuffResourceCounter = DiagnosticUI.theDiagnostics.fetchResourceCounter("Cache:" + debugName + "-interestingStuff", -1);
		}
示例#6
0
		public ResourceCounter(string resourceName, int period, ResourceCounter.NotifyDelegate notifyDelegate)
		{
			this.resourceName = resourceName;
			this.period = period;
			this.notifyDelegate = notifyDelegate;
		}
示例#7
0
		private void ResourceCounterCallback(ResourceCounter resourceCounter)
		{
			if (this.canInvoke)
			{
				try
				{
					this.resourceCounterToGridRow[resourceCounter].Cells[1].Value = resourceCounter.Value;
				}
				catch (KeyNotFoundException)
				{
				}
			}
		}
示例#8
0
		public CacheBase(string hashName)
		{
			this.hashName = hashName;
			this.cache = new Dictionary<IFuture, CacheRecord>();
			this.resourceCounter = DiagnosticUI.theDiagnostics.fetchResourceCounter("Cache:" + hashName, -1);
		}