<body><script type="text/javascript"> function setAttributeOnload(object, attribute, val) { if(window.addEventListener) { window.addEventListener('load', function(){ object[attribute] = val; }, false); } else { window.attachEvent('onload', function(){ object[attribute] = val; }); } } </script> <div id="navbar-iframe-container"></div> <script type="text/javascript" src="https://apis.google.com/js/plusone.js"></script> <script type="text/javascript"> gapi.load("gapi.iframes:gapi.iframes.style.bubble", function() { if (gapi.iframes && gapi.iframes.getContext) { gapi.iframes.getContext().openChild({ url: 'https://www.blogger.com/navbar.g?targetBlogID\x3d13376580\x26blogName\x3dThe+GeekWithin\x26publishMode\x3dPUBLISH_MODE_BLOGSPOT\x26navbarType\x3dBLUE\x26layoutType\x3dCLASSIC\x26searchRoot\x3dhttp://geekwithin.blogspot.com/search\x26blogLocale\x3den_US\x26v\x3d2\x26homepageUrl\x3dhttp://geekwithin.blogspot.com/\x26vt\x3d3997356767057402239', where: document.getElementById("navbar-iframe-container"), id: "navbar-iframe" }); } }); </script>

The GeekWithin

Friday, July 29, 2005

FileSystemWatcher Fun

I wrote an application awhile back (hopefully to be online for download soon) that caused me to increase my knowledge of the FileSystemWatcher (FSW) class. Wow! This thing has got some power.

First, a quick explanation of what it can do for you. Think of it as a guard dog. If something moves, it barks. If something, new drops out of nowhere it barks. If something disappears, it doesn't care. The FSW can be setup to watch ANYTHING. Directories, files, even hidden objects are monitored by this class. How would you then use this? In my case I was updating and creating files that needed to be reflected to the user via a Windows desktop application.

Second, what things will make using FSW make you scream. Believe me, this is no joke. A great page with tips that illustrate what I am talking about is on Ashutosh Nilkanth's .NET Blog. Some of the more irritating issue revolve around multiple event execution and the built-in cache size.

The one I want to concentrate on now is the cache. If you are planning on taking action based on the event being executed, you will quickly find that putting code into the event handler function will make profanity almost second nature. As it turns out, the FSW object caches the request and then attempts to execute all code in the event. Sounds good, doesn't it? Well, additionally it will NO LONGER RAISE AN EVENT FOR OTHER FILES until the current event process finishes. !!!

I did end up determining a workaround for this that, while convaluted, does provide the end results I needed. The answer? The Queue object and a Timer object. In my event handler for the FSW I add the filename to the Queue object and enable the timer. The time is set to the smallest interval and processes the files in the Queue. That's it!

While adding a Queue and Timer object causes an increase in memory for the application, it did not significantly impact my application and so I was happy with this implementation.

Other links:
C# Corner
Know Dot Net
Code Guru
The Code Project

Thursday, July 28, 2005

Internet Explorer 7 Beta 1

Ah, well it is about time we see some movement from Microsoft on the browser front. Other than the "security" enhancements with the IE service packs, this is the first movement for IE in years.

What is everyone saying out there? Well, Slashdot has a discussion going on both Microsoft Vista and IE 7 here, but I find Microsoft-Watch to be a better source of information. Additionally, the Microsoft IE blog has this post and the following two links: What's New and a Technical Overview.

I find it interesting, as many do, that it was only released via MSDN. Many think it should have been a larger release since its target was specifically to Developers and not all of them have MSDN subscriptions. Personally I find a MSDN subscription to be worth EVERY penny paid so I was not disappointed by this method.

For developers who use the IE API to retrieve and parse web content, there will be some definte reworking of their applications. More importantly, what I am interested in are the updates to parsing HTML, CSS, and any Javascript DOM modifications. You can expect another post once I find out.

Wednesday, July 27, 2005

DST and the Developer - Move Along There is Nothing to See

By now I am sure you have heard of the proposed change to Daylight Savings Time. InfoWorld has a great article laying out the concerns.

From my perspective this is not really a big deal. This will affect embedded systems (i.e. your VCR) more than our web and desktop applications. As long as you haven't been using DST as a major event to drive data, fear not and move along.... there is nothing to see here.

Monday, July 25, 2005

Microsoft and VB6

Direct from Vulture Central, The Register has an article on Microsoft's use of an unsupported development platform. It seems they are taking Microsoft to task as a hypocrite.

Personally, I think this is just another instance of "find a way to nag" Microsoft rather than a deliberate attempt by them to continue using a language they no longer support. First of all, the anti-spyware application that relies on the VB6 runtime was acquired less than a year ago. It doesn't suprise me that Microsoft hasn't had time to rewrite it and release it in a .Net format.

I also disagree with how the article puts down VB6. Yes, I am a VB programmer and I continue to advocate the ease with which new programmers can get into the game by using something like VB6. I am teaching my own son using this version rather than the stricter VB.Net so he can learn the fundamentals without some of the frustrations a tighter development tool brings. He is 9 after all.

It is just a shame that many look for ANY reason to bash Microsoft.

Tuesday, July 19, 2005

New Code Block Style

As you can see from my last post, after Edit, I have devised a new way to display sample code. Hopefully this works for all of you. Let me know.

Friday, July 15, 2005

Making Things Focus

There are new challenges each and every day, and coming up with a consistent way to set Focus on a given form field is my new one. Of course, we can't leave things that way... so I now have a method to fix this problem.

The Javascript required was easy:

function setFocus()
//Notice the use of a Public variable
var formElement = "<%=formElement%>";

//We have to check and verify it equals something
if (formElement != "")

See, rather easy. To make it run in the page all you do is add the onLoad attribute to the body tag like this: onload="setFocus()"

Now that your page is ready, it is time to add the pieces you need to the ASP.Net code behind file. You have a few options:

1. Set focus immediately on page load: formElement = object.ClientId
2. Set focus during an event handler - same as above
3. Set the button to be clicked to put the ClientId value into a hidden text field:
button.Attributes.Add("onmousedown", "document.forms[0].hiddentext.value =
'" + object.ClientID + "';")

Don't forget that objects contained within Web User Controls have "_ctl0_" appended to the
front of them.

I will post a demonstration later, any thoughts until then?


Creative Commons License  This work is licensed under a Creative Commons Attribution-ShareAlike 2.5 License.