Tuesday, March 30, 2010

Monday, March 29, 2010

C# Event Handlers

I didn't know this but events can cause memory leaks.



This is a blog that shows how C# 4.0 events will not need to be locked. ( didn't know 3.0 events needed to be locked. )

Also, events can cause memory leaks if the Handler is not disposed of. ( myHander = null ).

Tuesday, March 23, 2010

SQLite to CSV in Python

To begin this mission, I know nothing about Python.

In 20 minutes, I have a sqlite database outputting data to a csv file.

WOW!

import sqlite3

conn = sqlite3.connect('C:/SQLite/db.sql')
curse = conn.cursor()

data = curse.execute('select * from Data where DATETIME([DateTime]) >= DATETIME("2010-03-20 05:00:00") AND DATETIME([DateTime]) <= DATETIME("2010-03-20 15:00:00");')

f = open('output.csv', 'w')

for row in data:
print >> f, row


------


7 lines of code. Awesome.

Wednesday, March 10, 2010

Debugging a Windows Service without installing

Well, first, to install using installutil [myapp.exe], you must put an environment variable in your system. -> InstallUtil.exe is in Microsoft.NET folder.

Visual Studio 2008 will not let you Debug a windows service. In the Project Properties, in the Debug tab, put [some command line argument...like /c for console]. This will send a command line argument to your application.

Surround the

ServiceBase[] ServicesToRun;
ServicesToRun = new ServiceBase[]
{
new MainDataService()
};

ServiceBase.Run(ServicesToRun);

With an

if(commandLineArg == "/c")
{
[code above]
}

This will run your application in Visual Studio