|
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace DotNet40UIPerf
{
public partial class Form1 : Form
{
private const long TicksPerMiliSecond = TimeSpan.TicksPerSecond / 1000;
int _result = 0;
public Form1()
{
InitializeComponent();
}
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static int Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Form1 f = new Form1();
Application.Run(f);
return f._result;
}
protected override void OnActivated(EventArgs e)
{
base.OnActivated(e);
if (Environment.GetCommandLineArgs().Length == 1)
{
System.GC.Collect(2, GCCollectionMode.Forced);
System.GC.WaitForPendingFinalizers();
}
else if (this.WindowState == FormWindowState.Normal)
{
DateTime mainEntryTime = DateTime.UtcNow;
string launchtime = Environment.GetCommandLineArgs()[1];
DateTime launchTime = System.DateTime.FromFileTimeUtc(long.Parse(launchtime));
long diff = (mainEntryTime.Ticks - launchTime.Ticks) / TicksPerMiliSecond;
// string txt = label1.Text ;
//
// txt += " Activated";
// label1.Text = txt;
_result = (int)diff;
}
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
Decebal Mihailescu is a software engineer with interest in .Net, C# and C++.