Quantcast
Channel: Visual C# forum
Viewing all articles
Browse latest Browse all 31927

My Namespace Example - Garbage Collection

$
0
0

Hiya,

 Please review my namespace and give me some feedback. As always, suggestions, comment, tip, etc. are always

welcome. However, flaming, insults are always taboo. So try to be kind. Thanks. :)

using System;
using System.Runtime;

namespace GarbageCollection
{
    interface IgcGet
    {
	void Get();
    }

    interface IgcShow
    {
	void Show();
    }

    class gcStatus : IgcGet, IgcShow
    {
	private int gcCollectionCount;
	private int gcMaxGen;
	private bool gcServer;
	private long gcTotalMemory;
	private GCLatencyMode gcLatencyMode;
	private GCNotificationStatus gcNotifyStatus;

	public int CollectionCount { get { return gcCollectionCount; } }
	public int MaxGen { get { return gcMaxGen; } }
	public bool Server { get { return gcServer; } }
	public long TotalMemory { get { return gcTotalMemory; } }
	public GCLatencyMode LatencyMode { get { return gcLatencyMode; } }

	public void Get()
	{
	    gcMaxGen = GC.MaxGeneration;
	    gcTotalMemory = GC.GetTotalMemory( true );
	    gcCollectionCount = GC.CollectionCount( gcMaxGen );
	    gcServer = GCSettings.IsServerGC;
	    gcLatencyMode = GCSettings.LatencyMode;
	}

	public void Show()
	{
	    Console.WriteLine( "*****************************************" );
	    Console.WriteLine( "*          Garbage Collection           *" );
	    Console.WriteLine( "*****************************************" );
	    Console.WriteLine( " Description             Status          " );
	    Console.WriteLine( "-----------------------------------------" );
	    Console.WriteLine( " Max Generation            {0}", gcMaxGen );
	    Console.WriteLine( " Total Memory KB           {0}", gcTotalMemory / 1024 );
	    Console.WriteLine( " Collection Count          {0}", gcCollectionCount );
	    Console.WriteLine( " Server Enabled            {0}", ( gcServer == true ) ? "Yes" : "No" );
	    Console.WriteLine( " Latency Mode          {0}", gcLatencyMode.ToString() );
	    Console.WriteLine( "*****************************************\r\n" );
		}
	}
} // end namespace

The interface Get/Show was pretty fancy, i normally just oldschool it. :)



Viewing all articles
Browse latest Browse all 31927

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>