Still Alive

22 Jan

This blog is not dead!

But I’m not a .Net developer anymore…

Anyone interested in providing some fresh .Net related contents for this blog?

 

New year 2014

31 Dec

This is the last day of 2013.
2013, with all good and bad, happiness and sadness, hope and disappointment, joy and sorrow, sweetness and bitterness is now over.

Happy New Year!

Merry Christmas!

19 Dec

Long time no post! I know I know and I am very sorry for that.

I just came here to say Merry Christmas.

Project estimation with Use Case Points using Enterprise Architect (EA)

15 Dec

This post is about software development management.

Project estimation is one of the most challenging duties of project managers. Among various estimation methods, Use Case Points is the most reliable method.

If you are not familiar with UCP please read this article.

As you may know, Use Case Points method involves different factors and needs calculation. For most software project managers it seems difficult and time consuming to use it manually.

In this article I will show you how to estimate effort of a software project using Enterprise Architect (EA) which is a famous CASE tool.

Read the complete article in PDF here:

Project estimation with Use Case Points using Enterprise Architect

 

Update:

Sparx Systems, creator of EA, has published this article. Click  here to read it.

Thread Timer

24 Aug

There are three timer controls in the .NET Framework:

  • A Windows-based timer, which is always in the Visual Studio Toolbox (System.Windows.Forms.Timer)
  • A server-based timer, which you can add to the Visual Studio Toolbox (System.Timers.Timer)
  • A thread timer, which is available programmatically (System.Threading.Timer)

If you are using Windows Forms and probably updating a UI, use System.Windows.Forms.Timer.

For server-based timer functionality, you might consider using System.Timers.Timer, which is also more accurate and has additional features.

The third one, System.Threading.Timer, uses a separate thread for it’s operation. If you need to do an asynchronous job periodically, it may be useful.

Using  System.Threading.Timer:

System.Threading.Timer timer;
timer = new System.Threading.Timer(new TimerCallback(DoSomething), null, 0, 1000);

DoSomething() executes at specified intervals(1000 ms here). Note that DoSomething() does not execute on the thread that created the timer; it executes on a ThreadPool thread supplied by the system.

private void DoSomething(object obj)
{
//it executes every second
}

To enable/disable timer, use Change() method:

timer.Change(Timeout.Infinite, Timeout.Infinite); //disable
timer.Change(0, 1000); //enable

Simple Exception Logger

21 Apr

The following class is probably the world simplest text logger.
There are several ways to open a file and write texts into it but I used File.AppendAllText() method because by using this method, it is guaranteed that the file handle will be closed, even if exceptions are raised.

public static class Logger
{
	public static void Log(string message)
	{
		File.AppendAllText("C:\\MyLogFile.txt", DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString() + ":\t" + message + Environment.NewLine);
	}
}

Using the Logger class:
By handling Application.ThreadException event in Program.cs , you can log every un-handled exception into a text file for further examination.

static void Main(string[] args)
{
	Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException); //it must be before Application.Run
	...
	Application.Run();
}

static void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e)
{
	Logger.Log(e.Exception.ToString());
}

Monitoring access to your shared files on network

2 Mar

ShareMonitor snapshot

I have written a program (named ShareMonitor) that allows you to monitor any access to your network shared files.  When a user remotely opens shared files on your computer, application detects it and displays information such as who opened it, when it was opened, duration, etc. about that file. All details will be logged and can be saved to .CSV or .XML files for further analysis.
You can also disconnect any active connection whenever you want.

For more details and source code, visit ShareMonitor’s Code Project page.

Download ShareMonitor (from Softpedia)

Update:

Since it was published, many articles have been written by experts to introduce and recommend ShareMonitor. Here you can find some of them:

Happy new year!

1 Jan

happy new year from C# tips

I wish you a pleasant year…  full of C# tips 😉

Happy new year everybody.


How to run or deploy a .Net application without .Net framework installed?

29 Nov

Sometimes you may need to let user run your .Net application without installing .Net framework.
There are several tools called “.Net Linker” which pack a .Net application with all needed files into a single package.

Here are some of them:
http://www.vmware.com/products/thinapp/
http://spoon.net/Studio/
http://www.remotesoft.com/linker/

Multiple Cell Selection in DataGridView

9 Sep

DataGridView has a facility to select multiple cells (or a range of cells) using mouse dragging, Cltrl+Click or Shift+Click. This feature is similar to cell selection in spreadsheet applications such as Microsoft Excel.

In order to enable this feature in DataGridView, use ‘SelectionMode’ property as follows:

DataGridViewCell.SelectionMode = DataGridViewSelectionMode.CellSelect;

To read/write data from/to selected cells simply write:

foreach (DataGridViewCell cell in dataGridView1.SelectedCells)
{
	//read cell data
	MessageBox.Show(cell.Value.ToString());

	//change cell data
	dataGridView1.Rows[cell.RowIndex].Cells[cell.ColumnIndex].Value = 1;
}