now maybe i will get some peace! blooming soccer fans! i have no idea what makes soccer so captivating. it really does dey logic. my borther - who's a Man Utd fan - didn't eat until the match was finally over. i guess he realized that whatever happened, the players still don't realize his existence. and that's my problem with Nigerian supporters of foreign teams. don't they realize that for the most part, the players don't know they exist, nor care if they are cheered on by some people they'll never meet? and yet the madness continues. men who are never alive as far as their families are concerned suddenly come alive when there's a meet between "their team" and "the enemy". ridiculous. that's why i insist that football is demonic. the Bank PHB ad about La Liga really puts it in context.
Thursday, May 22, 2008
Monday, May 19, 2008
much as i would like to, this isn't a real tutorial about creating a Windows service in .NET. there are lots of excellent tutorials in that regard. this is just to highlight some problems i had recently when i created a service. usually, the service sits in the background, waiting for "something to happen", maybe a client connects, a timeout goes off, and all that. my service is a time-based service that performs certain actions when a timer goes off.
to get my service doing some "real" work, i used the
System.Timers.Timer class, which has the
Elapsed event, which calls a callback method when the timer fires. here's a caveat: the callback for the
Elapsed event suppresses all exceptions in .Net 2.0 and lower (i can't categorically say that the behaviour isn't the same in higher versions). forget processing unexpected exceptions in your callback - they'll get supressed. and you may end up like me: after putting in a full day at work, spending the night there, and putting in another full day, you're at the client's and the service runs but doesn't do anything.
my fix? in my callback, i start a separate thread. the thread takes responsibility for doing the processing that was in my callback, and i once again can see what exceptions occur in my processing. by the way, design your tables so none of your fields are allowed the
NULL value in .Net. use sensible defaults instead of
NULL, becaue you never know when you'll get a
System.DBNull object that isn't automatically converted to
null. later, then!
Edit: when services run - irrespective of where the executable actually is - the working directory is always
C:\WINDOWS\System32. that can be a problem if you access to files residing in the same location as the executable, especially if you don't know where the service executable is (if you think that is strange, think again: you - or someone else - could create an installer that allows the user customize the location of the install). if you need to get access to the executable's location, you can do:
string basepath = System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase;
file:///C:/..., so you'll need to trim off the beginning of the string returned.
i used SharpDevelop for creating my service, as creating the service from scratch (Visual C# 2008 Express) or tusing an application template (Visual Studio 2008) gave me problems when trying to install the service using
installutil. SharpDevelop integrates with FxCop, a code analysis tool developed by Microsoft. running FxCop on my executable showed me some things i'd never really noticed before, such as using
string.IsNullOrEmpty(variable) instead of
if ((variable == string.Empty) || (variable == null)) to check if a string was empty or null.
from time to time i hang out in ##csharp on Freenode. the guys there are great (mostly) - they've helped me out with quite a number of problems. and it's just plain fun to hang out with them. here's a excerpt from the conversation there this morning:
[11:39] <scruz> i don't ever want to be you - link managed and unmanaged code
[11:40] *** Mathius joined
[11:40] * scruz shivers at the thought of interop_madness' pain
[11:40] <Mathius> hi
[11:40] <interop_madness> you you don't want to be on the same planet as me
[11:40] <scruz> what planet is that?
[11:41] <+smellyhippy> Mathius: ello
[11:41] *** SDragon quit (Read error: 104 (Connection reset by peer))
[11:41] *** SDr joined
[11:41] <interop_madness> dunno, but it certainly has no sun shining
[11:41] <scruz> yello Mathius
[11:41] <Mathius> O_o
[11:41] <Mathius> hey hey
[11:41] <scruz> from Earth import Sun
[11:42] <Mathius> >_>
[11:42] <scruz> Sun.shine()
[11:42] <Mathius> public sealed class Earth : INoLight
[11:42] *** gregzx joined
[11:42] <scruz> lol
[11:42] <pandzilla> haha
[11:43] <Mathius> CSC Error: You cannot look for light in an instance of type 'Earth'.
Sunday, May 18, 2008
if you're like me, you like to use the latest software. that includes browsers. unfortunately, the latest browsers are a really bad idea if you're into web design - specifically standards-based design. because you need to workaround features not supported in older browsers. i made a really big mistake when designing a client's website - i designed it using the latest Firefox, Opera and IE7. it was okay in those browsers. imagine my shock when i viewed it in IE6 and it was fugly. and that was after deployment.
to avoid my mistake, you want to design using IE6. unfortunately, even i don't encourage you to use IE6. so how can you get IE6 for testing your web pages? well, i originally thought of using VirtualBox to create a WinXP disc image on my system - but that's a waste of about 2GB just to test web sites. so i went googling. and i came up with Multiple IEs. at first i thought it was just snake oil, especially when i ran IE6 and went to Help -> About. however, when i tested it, i got IE6's signature crappy rendering - and it was different from IE7's, so i'm quite happy advertising it. thanks to the guys over at TredoSoft!
i'm not sure why, but more and more, software installations tend to assume you have just one partition on your machine - that, or you absolutely don't mind it getting filled up with things you don't really know.
lost? let me explain: i'm in the habit of breaking up my harddisk into partitions. i used to leave 5GB on C: for OS files, taking into account that some software will always install some things on C: even if you tell the setup wizard to install on some other partition. that was enough about 4 years back. i upped it to 7.5GB sometime back, and finally to 10GB. now it seems even that isn't enough. i installed Visual Studio 2008 recently, and my free space on C: has plummeted down to less than 2.5GB - without enabling hibernate. i dread what would happen if i installed Adobe products - at least another 400MB would go should i install CS3 Design. yet i have over 14 GB lying fallow on a partition i reserved for installing application software. even with CCleaner installed, i can't free up any space. granted, a heavier-duty application can help with that, but i don't have much hope in that direction.
darn shame what they do to my disk space.
Friday, May 16, 2008
i just downloaded Shockwave Player 11 to install on my computer (yes, right now it seems nobody uses Shockwave anymore - Flash seems to have effectively killed Director) and i was surprised - no, shocked - to find the installer prompted me to install the Google toolbar. Google? what happened to Yahoo-integrated search in Adobe Reader? must be because i'm so tired...i'll check again when i do not feel so sleepy ;)